Cerca
Heus ací els resultats de la cerca.
Resultats de text complet:
- 2.3 A small lexicon of widgets - Part 3
- as it’s full equipment is extremely complex. Fortunately, we don’t need its entire flexibility when w... d, as the widget doesn’t take the focus itself. Run the code and test its behavior. <code python> im... lick) causes one of **two effects**: * **it launches** a callback bound to the option; * **it unrolls** a new menu (actually a submenu) * if you
- 1.6 Events and how to handle them
- ts. This also means that some of the events may launch some of your callbacks, which makes you respons... on a very helpful method we’ll use to arrange communication between you and your application. Of course, you can use the regular ''print()'' function to show messages and present a debug trace. ... the application to behave in a mature way. The function we’ll use for our experiments is named ''sho
- Python Professional Course Series: GUI Programming
- re that GUI is present nearly everywhere. Look around you – you’ll see a couple of different devices e... re every year) use it to display a GUI and to communicate with the user. They communicate bidirectionally. GUI stands for Graphical User Interface. In th... phical? We have to do a little time traveling to understand that. Don’t worry, it won’t take long. We
- 2.4 Shaping the main window and conversing with the user
- r what your application is named, or even if it's unnamed. To change the window’s title, you would us... ch changes its title each time you click over it, until you do it ten times, after which the title rem... rt tkinter as tk def click(*args): global counter if counter > 0: counter -= 1 window.title(str(counter)) counter = 10 window = tk
- 1.2 Let TkInter speak!
- ackage named **tkinter**. The package contains a bunch of functions, constants, classes, objects, and modules used to build GUI applications. The GUI app... t of necessary **widgets** to the window; * **launching** the event controller. That’s all. Really.... inter as tk</code> Okay, we know there’s no accounting for taste, but it’s definitely worth accounti
- 1.8 Interacting with widget methods
- at the sense of their existence is very closely bound to the unique features of **event programming**. The methods are named (assuming that ''Widget'' is... ng widget): <code python> Widget.after(time_ms, function) Widget.after_cancel(id) </code> * ''afte... 1000 ms) and the second **points to an existing function**; successful invocation of the method cause
- 2.1 A small lexicon of widgets - Part 1
- f them, however – it would bloat our course to an unmanageable size. We’re convinced that our collecti... pp1:m3:pasted:20231228-105137.png}} Analyze and run the code in the editor – we wrote it to show you ... f the ''checkbutton'' and does two things: * counts all the ''checkbutton''’s state changes and sto... nter as tk from tkinter import messagebox def count(): global counter counter += 1 def show
- 1.5 A simple GUI application
- e and rather useless GUI application. Does that sound weird? Maybe, but the application, when ready, w... tely **obvious** – we'll construct a window and launch an event controller – look at the code in the e... on'' will be completely **mute**, as we haven’t bound anything to its command property. You can change... re used by ''tkinter'' to **organize internal communication between different widgets**. A regular var
- 1.4 Coloring your widgets
- f ''Button'' but don't forget that these ways are universal and can be used virtually everywhere. Let's check if tkinter understands **English** – look at the code in the ed... cation: ''bg'' (what is a short form of //“background-color”//) and ''fg'' (//“foreground-color”//). We went along the line of least resistance here – we'
- 1.7 Visiting widgets’ properties
- ontrary one; * **update** the button’s title. Run the code and observe its behavior. The second me... e> Let’s rewrite our code to use this way of communicating with the widget’s properties. Look at the... owing strings: * "bold" * "italic" * "underline" * "overstrike" Do you want to see it... ton_2["padx"] = 10 button_2["pady"] = 5 button_2["underline"] = 1 window.mainloop() </code> This is w
- 2.2 A small lexicon of widgets - Part 2
- r as tk def to_string(x): return "Current counter\nvalue is:\n" + str(x) def plus(): global counter counter += 1 text.set(to_string(counter)) counter = 0 window = tk.Tk() button = tk.Button(window, te
- 1.9 Looking at variables
- variables == Variables To implement some of its functions, Tkinter uses a very special kind of variab... th a number of **observers**. An observer is a **function** (a kind of callback) which will be invoked... the object through ''del'') * a reference to a function which will be invoked when the specified event occurs. The function returns a string which is a unique observer
- 1.3 Settling widgets in the window's interior
- nd to **find the best location** for each widget. Unfortunately, its assumptions may not live up to your expectations, and the final result can be really ... Only one of them can be used in one application, unless you want to turn your window into a big mess.... g to affect the buttons’ relation to the cells’ boundaries. Can you see what we changed in the code?
- 2.5 Working with the Canvas
- 0 x 400-pixel **canvas** with a **yellow** background. Next, it draws a line (precisely: a polygonal *... ame as for ''create_polygon()''. Let’s test it. Run the code we've provided in the editor. <code pyt... ''PhotoImage'' class object using an ''ImageTk'' function of the same name; * continue as usual. The