Cerca

Heus ací els resultats de la cerca.

Python Professional Course Series: GUI Programming
22 Resultats, Darrera modificació:
= Python Professional Course Series: GUI Programming == What is GUI? GUI is an acronym. Moreover, it’s... mmunicate bidirectionally. GUI stands for Graphical User Interface. In this three-word acronym, the U... ut what does it mean that the interface is graphical? We have to do a little time traveling to unders... d and completely separate device called a **terminal**. The terminal needed to be wired to a computer
1.3 Settling widgets in the window's interior
14 Resultats, Darrera modificació:
may not live up to your expectations, and the final result can be really disappointing. This method o... ers. It gives you a chance to express your **general wishes** and tries to deploy the widgets according to them. Note the word general – they aren't as precise as the ones used by plac... ''x=x'' – the widget's top-left pixel's **horizontal coordinate** measured relative to the home window
1.2 Let TkInter speak!
13 Resultats, Darrera modificació:
he GUI application itself consists of four essential elements: * **importing** the needed **tkinter... recisely: which creates an **alias** of its original name) at the time of import. **tk** looks shorte... arget window) is obligatory. All others are optional. The one named **text** sets the initial button's title (note: the title can be changed at any time)
1.7 Visiting widgets’ properties
12 Resultats, Darrera modificació:
do this in the following way: <code python> old_val = Widget["prop"] Widget["prop"] = new_val </code> Let’s see it in action. Look at the example we've... hon> import tkinter as tk def on_off(): global button state = button["text"] if state ==... This is what they look like: <code python> old_val = Widget.cget("prop") Widget.config(prop=new_val
2.3 A small lexicon of widgets - Part 3
10 Resultats, Darrera modificació:
y when you are going to ask the user for any textual information: name, password, email, etc. The widg... t tkinter as tk def digits_only(*args): global last_string string = text.get() if string... aits: * a classic menu is actually a **horizontal bar** located at the top of the application windo... g; * line 9: main window creation (nothing special at all) * line 12: we create the main menu obje
2.5 Working with the Canvas
10 Resultats, Darrera modificació:
round. Next, it draws a line (precisely: a polygonal **chain**) consisting of three line segments. The... first argument specifies the master widget (as usual). A set of keyword arguments specifies the proper... et of methods designed to create different graphical constructs. To create a polygonal chain, you need to use the one named ''create_line()'': <code pytho
2.4 Shaping the main window and conversing with the user
7 Resultats, Darrera modificació:
import tkinter as tk def click(*args): global counter if counter > 0: counter -= 1 ... it directly invokes one of the ''tkinter'' internal, low-level mechanisms directly communicating with... constructor to convert the PNG file into an internal ''tkinter'' representation (''PhotoImage()'' is a... </code> where ''width'' and ''height'' are decimal numbers specifying both dimensions in pixels. No
1.6 Events and how to handle them
6 Resultats, Darrera modificació:
inside the info string. And this is what the final message box looks like: {{ :info:cursos:pue:pyth... med ''wid'', and you’re going set its value to ''val'', you can use the ''config()'' method, just like here: <code python>wid.config(prop=val)</code> This means that if you want to unbind yo... tkinter import messagebox def on_off(): global switch if switch: button_2.config(com
2.1 A small lexicon of widgets - Part 1
6 Resultats, Darrera modificació:
We think the ''Button'' doesn’t require any special attention, as we’ve used it many times before. Yo... tk.DISABLED: button_1.config(state=tk.NORMAL) button_1.flash() else: butto... tkinter import messagebox def count(): global counter counter += 1 def show(): message... tkinter import messagebox def count(): global counter counter += 1 def show(): messag
1.4 Coloring your widgets
5 Resultats, Darrera modificació:
ton'' but don't forget that these ways are universal and can be used virtually everywhere. Let's chec... fer to **raised** buttons only. There two additional parameters describing the second set of colors na... ting with a **hash** (#) followed by **6 hexadecimal** digits. Each p**air of the digits** forms the v... ee pairs (RR, GG and GG) are **two-digit hexadecimal number** so: * #000000 is **black** * #FFFFF
1.5 A simple GUI application
5 Resultats, Darrera modificació:
' **habits** and **conventions**. Our fabulous goal will look like the vision presented below: {{ :in... non-clickable widget able to **present short textual information**, passed to the widget's constructor... class are used by ''tkinter'' to **organize internal communication between different widgets**. A regu... tch object. The assignment creates a **bidirectional link** between the object and the widget. How doe
1.9 Looking at variables
4 Resultats, Darrera modificació:
t some of its functions, Tkinter uses a very special kind of variable called an **observable variable*... ’s state can be **observed** by a number of external agents. For example, the ''Entry'' widget can use... the input field have been changed. From a technical point of view, such a variable is an object of th... r(id, ix, act): : : </code> * ''id'' – an internal observable variable identifier (unusable for us);
1.8 Interacting with widget methods
3 Resultats, Darrera modificació:
xpects two arguments: the first is a **time interval specification** (expressed in milliseconds: 1 s =... thon> import tkinter as tk def blink(): global is_white if is_white: color = 'black'... e ''jumpthefocus()'' function to organize a cyclical focus journey around all the buttons. We’ll say
2.2 A small lexicon of widgets - Part 2
3 Resultats, Darrera modificació:
le** category. They’re designed to present **textual** information and don’t have a ''command'' proper... nter\nvalue is:\n" + str(x) def plus(): global counter counter += 1 text.set(to_string(c... * of the window and to treat it as a kind of //local window//. Such a //window works// as a **master w