Cerca
Heus ací els resultats de la cerca.
Resultats de text complet:
- 2.3 A small lexicon of widgets - Part 3
- widget doesn’t take the focus itself. Run the code and test its behavior. <code python> import tkinter as tk def digits_only(*args): global last_string string = text.get()... y.pack() entry.focus_set() window.mainloop() </code> Try to modify the code to allow the user to ent
- 2.4 Shaping the main window and conversing with the user
- may want to change is its **title**. The title is defaultly set to ''Tk'', no matter what your applica... uld use a method named ''title()''. Our sample code shows a window which changes its title each time ... t ten times, after which the title remains 0. <code python> import tkinter as tk def click(*args): global counter if counter > 0: count
- 1.2 Let TkInter speak!
- our essential elements: * **importing** the needed **tkinter** components; * **creating** an appl... cilities is to import the package as a whole: <code python>import tkinter</code> Note: it won’t allow you to access some modules built-in within the pac... * looks shorter than **tkinter**, doesn’t it? <code python>import tkinter as tk</code> Okay, we kno
- 1.6 Events and how to handle them
- e user’s actions. Now it’s time to show you some details of the events’ lives and anatomy. We’ll also... print()'' function to show messages and present a debug trace. The output will appear in the standard ... window. It’s okay if used in the early stages of development, but it’s very inelegant if you want the... it needs **two arguments** which are strings: <code ; output> messagebox.showinfo(title, info) </code
- Python Professional Course Series: GUI Programming
- ook around you – you’ll see a couple of different devices equipped with screens: phone, tablet, comput... r too – it’s a tool used by the user to command a device and to receive its responses. But what does ... ical? We have to do a little time traveling to understand that. Don’t worry, it won’t take long. We’r... uch a computer?” To control the computer, you needed to have a specialized and completely separate de
- 2.5 Working with the Canvas
- ing with the Canvas == Canvas Our last meeting is devoted to the ''Canvas'' – a widget that behaves li... tart with a simple example. Take a look at the code. <code python> import tkinter as tk window = tk.Tk() canvas = tk.Canvas(window, width=400, height=... n = tk.Button(window, text="Quit", command=window.destroy) canvas.grid(row=0) button.grid(row=1) windo
- 1.3 Settling widgets in the window's interior
- of putting the widgets (not only the buttons) inside windows. There are more of them than just ''place... by **geometry managers**. ''Place'' is the most detailed one. It forces you to **precisely declare a widget's location**, pixel by pixel. It won't, howe... r to place some of them, partially or fully, outside the window. If you don't want to deploy the widg
- 1.7 Visiting widgets’ properties
- based on using a **dictionary** which exists inside every widget. Assuming that a widget named ''Widg... value, you can 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 provided in the editor. <code python> import tkinter as
- 1.8 Interacting with widget methods
- uming that ''Widget'' is an existing widget): <code python> Widget.after(time_ms, function) Widget.after_cancel(id) </code> * ''after()'' – this method expects two argume... t usable? Yes, it is, e.g., when you are going to delete the previously planned invocation from the ma... d)'' – the method cancels the planned invocation identified by the **id** argument. Seems confusing?
- 2.2 A small lexicon of widgets - Part 2
- fall into the **non-clickable** category. They’re designed to present **textual** information and don’... ''Label'' widget displays some lines of text inside the window: <code python> label = Label(master, option, ...) </code> The ''Label'' widget contains two usable properti
- 1.4 Coloring your widgets
- ts == Adding colors Nearly everything you put inside your windows may be **colored**. Most widgets have dedicated properties to handle their colors and we w... rtant thing is getting to know how the colors are described in ''tkinter'', in other words, what means can you use to order the button to be red or blue. There are at leas
- 1.9 Looking at variables
- to store values which are accessible to the outside world) but there is something more – any change o... g type, you’ll create it in the following way: <code python> s = StringVar() </code> If you want to **assign a value** to an observable variable, you hav... tring to a variable of the ''StringVar'' kind: <code python> strng.set("To be or not to be") </code> I
- 1.5 A simple GUI application
- ow and launch an event controller – look at the code in the editor to see how to do it. <code python> import tkinter as tk window = tk.Tk() window.mainloop() </code> Our window looks like this one for now: {{ :inf... e changed at any moment of the widget's life. <code python> import tkinter as tk window = tk.Tk() l
- 2.1 A small lexicon of widgets - Part 1
- ome of the ''tkinter'' widgets. We aren’t able to describe all of them, however – it would bloat our c... e of the widgets. In these cases, we’ll limit our descriptions to the necessary minimum. Each ''tkint... he widget that owns the newly created object. <code python> widget = Widget(master, option, ... ) </code> The master widget is just the main window in mo