Cerca
Heus ací els resultats de la cerca.
Resultats de text complet:
- 2.3 A small lexicon of widgets - Part 3
- racer remembers its **previous** state (using the last_s variable) and restores the field to this stat... kinter as tk def digits_only(*args): global last_string string = text.get() if string ==... g.isdigit(): # Field's content is valid. last_string = string else: text.set(last_string) last_string = '' window = tk.Tk() text =
- 1.6 Events and how to handle them
- ents. This also means that some of the events may launch some of your callbacks, which makes you respo... your application. Of course, you can use the regular ''print()'' function to show messages and presen... en; * the **second** string is a message to display inside the box; the string can be of **any length** (but remember, the screen isn’t elastic and won’t stretch if you’re going to display
- 1.5 A simple GUI application
- lutely **obvious** – we'll construct a window and launch an event controller – look at the code in the... this dull gray area. Our new friend is called ''Label'' – a non-clickable widget able to **present s... nstructor using a ''text'' argument. The text can later be changed at any moment of the widget's life.... e python> import tkinter as tk window = tk.Tk() label = tk.Label(window, text = "Little label:") lab
- 2.2 A small lexicon of widgets - Part 2
- property, although you can use ''bind()'' to simulate similar behavior. The ''Label'' widget displays some lines of text inside the window: <code python> label = Label(master, option
- Python Professional Course Series: GUI Programming
- letter acronym, a representative of a well-known class of acronyms which plays a very important role in the IT industry. Okay, that’s enough jokes about TLA’s for one course, all the more that GUI is presen... and many (more and more every year) use it to display a GUI and to communicate with the user. They com
- 1.7 Visiting widgets’ properties
- e** and **behavior**. We’ll show you how to manipulate properties and present a basic set of the most ... utton(window, text="OFF", command=on_off) button.place(x=50, y=100, width=100) window.mainloop() </co... utton(window, text="OFF", command=on_off) button.place(x=50, y=100, width=100) window.mainloop() </co... resenting a piece of text (e.g., ''Button'' and ''Label'' but not ''Frame'') can be made to use a font
- 1.3 Settling widgets in the window's interior
- side windows. There are more of them than just ''place()'', which you learned about in the previous se... ods are implemented 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... m some common mistakes causing the widgets to overlap each other or to place some of them, partially o
- 1.2 Let TkInter speak!
- ackage contains a bunch of functions, constants, classes, objects, and modules used to build GUI appli... set of necessary **widgets** to the window; * **launching** the event controller. That’s all. Reall... he simplest (and at the same time the less controllable) way of importing tkinter facilities is to imp... in fact, a reflection of an object of the Button class. To bring a button to life, you have to: * c
- 2.4 Shaping the main window and conversing with the user
- file='logo.png')) window.bind("<Button-1>", lambda e: window.destroy()) window.mainloop() </cod... e provided by you. The icon is transferred by the last method’s argument, but if you want this to work... pplication resides; * **use** a ''PhotoImage'' class constructor to convert the PNG file into an int... mage(file='logo.png')) window.bind("<Button-1>;", lambda e: window.destroy()) window.mainloop() </cod
- 2.5 Working with the Canvas
- = 2.5 Working with the Canvas == Canvas Our last meeting is devoted to the ''Canvas'' – a widget that behaves like a... **canvas**. It’s a flat, rectangular surface that you can cover with drawings, text, frames, and other widgets. Please treat... s = tk.Canvas(window, width=400, height=400, bg='black') canvas.create_rectangle(200, 100, 300, 300, o
- 1.8 Interacting with widget methods
- he method causes the event manager to change its plans; when the number of milliseconds elapses, the manager **will invoke the function** (only once); not... the method itself – it’s a unique **id** of the planned invocation; is it usable? Yes, it is, e.g., when you are going to delete the previously planned invocation from the manager’s calendar, which
- 1.9 Looking at variables
- rvable variable**. This variable works like a regular variable (i.e., it’s able to store values which ... such a variable is an object of the **container class**. This means that a variable of that kind has ... – if you want to be aware of the variable’s annihilation (removing the object through ''del'') * a r... t to know its meaning. The observer should be declared as a **three-parameter function**: <code pytho
- 1.4 Coloring your widgets
- east resistance here – we've just made use of regular English names of colors and packed them inside s... t some of your widgets to be simply **white**, **black**, **green**, **gray** or even **grey**. It's e... ightSalmon", activeforeground="LavenderBlush", activebackground=... idely used in many application, e.g. in color displays of different kinds. One of the RGB model imple
- 2.1 A small lexicon of widgets - Part 1
- able size. We’re convinced that our collection is large enough to make you familiar with ''tkinter'' s... '' widget is created by a **constructor** of its class. The very first argument of the constructor inv... in most cases, but can be also a ''Frame'' or a ''LabelFrame'' (described in the next section). The c... utton_1.config(state=tk.NORMAL) button_1.flash() else: button_1.flash() bu