Cerca
Heus ací els resultats de la cerca.
Resultats de text complet:
- 1.2 Let TkInter speak!
- Inter is a package named **tkinter**. The package contains a bunch of functions, constants, classes, objects, and modules used to build GUI applications. The GUI application itself consists of four essential elements: * **importing... gets** to the window; * **launching** the event controller. That’s all. Really. Looks too good to be
- Python Professional Course Series: GUI Programming
- et, fridge, oven, even washing machine or heating controller – all these things have a screen, most of ... Okay,” you may say, “nice image, but how could we control such a computer?” To control the computer, you needed to have a specialized and completely separa... building, a different city or even on a different continent. But the most intriguing part of the story
- 2.3 A small lexicon of widgets - Part 3
- d restores the field to this state if its current contents are invalid. Note: we’ve had to use the ''f... if string == '' or string.isdigit(): # Field's content is valid. last_string = string el... at the top of the application window; * the bar contains a number of horizontally deployed **options*... quired submenus (this is called a **cascade**) or connect a single callback. We’ll show you the whole p
- 1.6 Events and how to handle them
- e able to influence a widget’s state, and how you control the event manager’s behavior. For now, howev... ce. The output will appear in the standard Python console, without affecting the application window. It... } If your widget is a **clickable** one, you can connect a callback to it using its ''command'' proper... y, while the property can be initially set by the constructor invocation. We’ve already practiced this
- 1.7 Visiting widgets’ properties
- s state; * **change** the button’s state to the contrary one; * **update** the button’s title. Run... ad** the property’s value, and the second named ''config()'', which allows you to **set** a new value t... ode python> old_val = Widget.cget("prop") Widget.config(prop=new_val) </code> Let’s rewrite our code ... = "OFF" else: state = "ON" button.config(text=state) window = tk.Tk() button = tk.But
- 2.4 Shaping the main window and conversing with the user
- = 2.4 Shaping the main window and conversing with the user The main window is a very specific construct, as its fate is shared among **two** master... ation resides; * **use** a ''PhotoImage'' class constructor to convert the PNG file into an internal ''tkinter'' representation (''PhotoImage()'' is a par
- 2.1 A small lexicon of widgets - Part 1
- d bloat our course to an unmanageable size. We’re convinced that our collection is large enough to make... nimum. Each ''tkinter'' widget is created by a **constructor** of its class. The very first argument of the constructor invocation is always the **master widget*... abelFrame'' (described in the next section). The constructor accepts a set of arguments that configure
- 1.5 A simple GUI application
- e accustomed to some ''tkinter'' **habits** and **conventions**. Our fabulous goal will look like the ... art with something absolutely **obvious** – we'll construct a window and launch an event controller – look at the code in the editor to see how to do it. <... ort textual information**, passed to the widget's constructor using a ''text'' argument. The text can l
- 2.5 Working with the Canvas
- t draws a line (precisely: a polygonal **chain**) consisting of three line segments. The application ca... w you how to create a canvas. This is done with a constructor named Canvas(). <code python> c = Canvas... of methods designed to create different graphical constructs. To create a polygonal chain, you need to ... yn, option...) </code> The method draws a line connecting the points of specified coordinates (xi,yi
- 1.3 Settling widgets in the window's interior
- loy the widgets manually and worry about possible conflicts and failures, you may entrust the whole pro... w it belongs to (it gets the information from the constructor's very first argument). The most usable ... As you can see, using ''place()'' gives you full control over the window's image. There is only one important but — full control means full responsibility. Sometimes it's bet
- 2.2 A small lexicon of widgets - Part 2
- aster, option, ...) </code> The ''Label'' widget contains two usable properties, but you need to remem... panied by an observable variable can be used to **continuously** update the ''Label''’s contents. <code python> import tkinter as tk def to_string(x): ... e updates. The ''Frame'' widget is, in fact, a ''container'' designed to store other widgets. This mea
- 1.8 Interacting with widget methods
- (only once); note: this the only possible way of controlling the **passage of time** when using an eve... ocation identified by the **id** argument. Seems confusing? Not at all. The example will shed more lig... r = 'white' is_white = not is_white frame.config(bg=color) frame.after(500, blink) is_whi... ame widget is packed into the main window; * we continue to encourage it every time the ''blink()'' f
- 1.9 Looking at variables
- ervable variable to inform other objects that the contents of the input field have been changed. From ... nt of view, such a variable is an object of the **container class**. This means that a variable of that... Var * StringVar The names you see are also the constructors’ names, so if you want to use any of the variables, you must invoke the proper constructor and save the returned object. Note: the
- 1.4 Coloring your widgets
- </code> Note the two new arguments we use in the constructor invocation: ''bg'' (what is a short form ... activebackground'' respectively used by the event controller when the button is **pressed**. Do you wan... called **color components**) so the full spectrum consists of 256*256*256 = 16,777,216 colors. An average human can distinguish about 7 million colors, consequently, the model should work well and it reall