This example describes a Python-based tkinter implementation of Notepad. Share to everyone for your reference. Specific as follows:
From Tkinter Import *root = Tk ("Simple Editor") Mi=stringvar () Label (text= ' Please input something you like~ '). Pack () Te = Te XT (height = 30,width =100) te.pack () Label (text= ' File name '). Pack (side = left)
The example in this paper describes how Python implements a simple text editor based on the Tkinter library. Share to everyone for your reference. The implementation method is as follows:
# # {{http://code.activestate.com/recipes/578568/(r1) from Tkinter Import * from Tksimpledialog import Askstringfrom TkF Iledialog Import asksaveasfilenamefrom tkmessagebox Imp
#!/usr/bin/python#-*-coding:utf-8-*-if __name__=='__main__': fromTkinterImport*Root= Tk ()#Tk () is a function in the Tkinter library.Root.title ('What the hell?') Canvas=Canvas (root, Width= 400,#width of canvasHeight = 400,#the height of the canvasBG ='Red' #Beijing color of canvas) X0= 20y0= 20Y1= 275X1= 275#RectangleCanvas.create_rectangle (X0,y0,x1,y1,fill ='Yellow')#Rectangle Two coordinate poin
The example in this article shows the Python Tkinter method for implementing a simple layout, with a more detailed annotation for the reader to understand. Share for everyone to use for reference. as follows:
#-*-Coding:utf-8-*-from tkinter import * root = Tk () # 80x80 represents the size of the main window at initialization time, 0, 0 represents the locat
There's a basic understanding of Python, always want to do something have been struggling to find a good practice, this does not work, need to do the project plan, the project needs to be based on 3 known parameters to calculate other parameters, as well as the stability of the parameters of the state, so intend to use this to familiarize yourself with Python, Although this program is not very robust, and d
coordinates, which defines the width (in pixel units) for each column. Event.x/y can take the coordinates. You can analyze the coordinate range of the column in which the coordinate falls.Header_widths=[n1,n2,n3 ....] row_selected = Your_treeview.identify_row (event.y) values = Your_treeview.item (row_selected, ' values ') Cell_val = Falseindex = -1t=event.xfor i in range (header_widths): if t>0: t=t-self.form_bom_line_widths[i] else: index=i-1 breakif index!=-1: c
Mainly based on the Colorsys implementation, the example is from HLS to RGB, if you want to change the color space very easy only need to change a functionScale and canvas components are usedThe code is as follows:from Tkinter import *import colorsys# operation response Function def update (* args): ' color ' r,g,b = col Orsys.hls_to_rgb (H.get ()/255.0, L.get ()/255.0, S.get ()/255.0) R,g,b = R * 255, G * 255, B * 255 rgb.configure ( Text = ' RGB: (%
The menu operations in python tkinter are mentioned in the previous blog.
The following are single-choice menus and unavailable menu operations.
:
tkinter * = { : : : : : checked_box = radio_items = [, , , , , , , opinion = root = root.geometry( root.t
"File MD5 validation Tool" written using Python 2.7.10 tkinter. Due to their own level of problems, there may be some mistakes, I beg you to correct, thank you.Graphical interface:650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M00/77/70/wKiom1Zn13bQQrW6AAAy18QQ_lk918.png "title=" 002. PNG "alt=" Wkiom1zn13bqqrw6aaay18qq_lk918.png "/>Source:#coding:utf-8#pythontkinter file MD5 Check # environment Pyt
position the component. But it is not recommended to use, at different resolutions, the interface tends to have a large difference.Place parameterAnchor: Location, default value NW same pack layoutX, Y: The x, y-coordinate integer in the upper-left corner of the component, the default value 0 absolute position coordinates, per pixelRelx, rely: The relative position of floating-point numbers between components relative to the X, y-coordinate 0~1 of the parent container, 0.0 for the left edge (or
#-*-Coding:utf-8-*-from Tkinter Import *root = Tk () # 80x80 represents the size of the main window at initialization, 0, 0 represents the location of the window at the time of initialization root.geometry (' 80x80+10+10 ' # Fill in Direction ' ' label (root, Text = ' L1 ', bg = ' red '). Pack (fill = Y) label (root, Text = ' L2 ', bg = ' green '). Pack (fill = BOTH) label (root, Text = ' L3 ', bg = ' blue '). Pack (fill = X) # Around layout label (ro
The TopLevel (top-level window) component is similar to a frame component, but the TopLevel component is a stand-alone top-level window that usually has parts such as title bars, borders, and so on, and is the same as the root window created by TK (), sharing the same method.
When to use the TopLevel component.
TopLevel components are typically used to display additional windows, dialogs, or other pop-up windows.
In the following example, we add a button to the root window to create a top-leve
Python Tkinter simple layout Learning
#-*-Coding: UTF-8-*-from Tkinter import * root = Tk () #80x80 indicates the size of the main window during initialization, and indicates the location of the window during initialization as root. geometry ('80x80 + 10 + 10') # Fill direction ''' Label (root, text = 'l1', bg = 'red '). pack (fill = Y) Label (root, text = 'l2',
In the tkinter module of python, menus can also be customized by you.
Below is my demo
Running effect:
tkinter * number = number += 1 tk = tk.geometry( tk.title(% ( ( Command_button = Menubutton(mBar, text= underline= Command_button.pack(side=LEFT, padx=
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.