Python+opencv+tkinter Integrated Demo
Because of the need to use OPENCV for small demo development, but because the OPENCV with the GUI function is still very simple, so use opencvv+tkinter combination implementation.
First, the result chart.
In the GUI click on the point of Praise button in the console can show "Someone to give you a little praise."
Directly on the code:
fromTkinterImport*ImportCv2 fr
>>> from tkinter import * >>> ROOT=TK () Create a new >>> window=toplevel (Root) # Create a new frame, window is the child window of root >>> window.title ("New Window") #窗口的标题 changed to new Window ' > >> window.lower () #最小化这个window >>> window.lower () >>> window.lift (Root) #重新显示window to Raise this window to the top of the "stacking" order in the window manager, call this method with no arguments. can also raise it to a position in the s
# XXX to do:#-Popup menu#-Support partial or total redisplay#-Key bindings (instead of quick-n-dirty bindings on canvas ):#-Up/down arrow keys to move focus around#-Ditto for page up/down, home/end#-Left/right arrows to expand/Collapse move out/in#-More Doc strings#-Add icons for "file", "module", "class", "method"; better "Python" icon#-Callback for selection ???#-Multiple-item selection#-Tooltips#-Redo geometry without magic numbers#-Keep track of object IDs to allow more careful cleaning#-Op
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) Entry (textvariable = mi). Pack ( Side = left
_ Tkinter. TclError: no display name and no $ DISPLAY environment variable, displayvariable
_ Tkinter. TclError: no display name and no $ DISPLAY environment variable
This is a problem that occurs when you use the pluginx inx of the cocos2d-x. In a win32 environment, run gameDevGuide. sh with cygwin, and this prompt appears.
The solution is relatively simple. In the cygwin directory, delete the python-
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 Import Askokcancel class Quitter (Frame): Def __
', Wraplength=50,width=30,height=10, BG='Blue', fg='Red', anchor='NW') (4) Bitmap Description: Displays the built-in bitmap. If the image option is specified, this option is ignored. The following bitmaps are valid on all platforms: Error, gray75, gray50, gray25, Gray12, Hourglass, info, questhead,question, and warning. Label=tkinter.label (root,bitmap='Error') (5) FG BG Description: Set foreground and background colors label=tkinter.label (root,text='helloworld!', fg='Red', bg='Blue') (A). Use
Tkinter supports three kinds of geometry managers: Grid Manager, Package Manager, location ManagerTip: Because each manager has its own style of placing widgets, it is best not to use multiple managers in small artifacts in the same container. You can use the framework as a sub-container to get the desired layout.1. Grid Manager#Geometry Manager (1)-----grid Manager" "The grid manager places the widget in each cell that is not visible to the grid. You
#!/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 point (x0,y0) (x1,y1) starting and ending point o
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', bg = 'green '). pack (fill = BOTH) Label (roo
Tkinter supports three kinds of geometry managers: Grid Manager, Package Manager, location ManagerTip: Because each manager has its own style of placing widgets, it is best not to use multiple managers in small artifacts in the same container. You can use the framework as a sub-container to get the desired layout.1. Grid Manager#Geometry Manager (1)-----grid Manager" "The grid manager places the widget in each cell that is not visible to the grid. You
Town Field Poem:The Pure Heart sentiment wisdom language, does not have the world name and the benefit. Learn water under the hundred rivers, give up arrogant slow meaning.Learn to have a small return to feed root, willing to cast a conscience blog. Sincere in this writing experience, willing to see the text to inspire.——————————————————————————————————————————CodeFrom Tkinter import *root=tk () #创建一个框架, responding to event frame=frame (root,width=200
Town Field Poem:The Pure Heart sentiment wisdom language, does not have the world name and the benefit. Learn water under the hundred rivers, give up arrogant slow meaning.Learn to have a small return to feed root, willing to cast a conscience blog. Sincere in this writing experience, willing to see the text to inspire.——————————————————————————————————————————CodeFrom Tkinter import *root=tk () Menubar=menu (root) Userchoice=intvar () Userchoice.set
Town Field Poem:The Pure Heart sentiment wisdom language, does not have the world name and the benefit. Learn water under the hundred rivers, give up arrogant slow meaning.Learn to have a small return to feed root, willing to cast a conscience blog. Sincere in this writing experience, willing to see the text to inspire.——————————————————————————————————————————CodeFrom Tkinter import *root=tk () S1=scale (root,from_=0,to=42,resolution=5) #默认是竖着的s1. Pa
Town Field Poem:The Pure Heart sentiment wisdom language, does not have the world name and the benefit. Learn water under the hundred rivers, give up arrogant slow meaning.Learn to have a small return to feed root, willing to cast a conscience blog. Sincere in this writing experience, willing to see the text to inspire.——————————————————————————————————————————Code From tkinter Import *root = Tk () Content=stringvar () Content.set (' can be checked '
Town Field Poem:The Pure Heart sentiment wisdom language, does not have the world name and the benefit. Learn water under the hundred rivers, give up arrogant slow meaning.Learn to have a small return to feed root, willing to cast a conscience blog. Sincere in this writing experience, willing to see the text to inspire.——————————————————————————————————————————Code From tkinter Import *root = Tk () def test (): If Inputstr.get ()! = ' House of Fame a
Town Field Poem:The Pure Heart sentiment wisdom language, does not have the world name and the benefit. Learn water under the hundred rivers, give up arrogant slow meaning.Learn to have a small return to feed root, willing to cast a conscience blog. Sincere in this writing experience, willing to see the text to inspire.——————————————————————————————————————————Code From Tkinter import *root=tk () Mylb=listbox (root) mylb.pack () mylist=["Greedy Wolf"
Town Field Poem:The Pure Heart sentiment wisdom language, does not have the world name and the benefit. Learn water under the hundred rivers, give up arrogant slow meaning.Learn to have a small return to feed root, willing to cast a conscience blog. Sincere in this writing experience, willing to see the text to inspire.——————————————————————————————————————————CodeFrom tkinter Import *root = Tk () def test (content,reason,name): if content = = "House
Town Field Poem:The Pure Heart sentiment wisdom language, does not have the world name and the benefit. Learn water under the hundred rivers, give up arrogant slow meaning.Learn to have a small return to feed root, willing to cast a conscience blog. Sincere in this writing experience, willing to see the text to inspire.——————————————————————————————————————————CodeFrom Tkinter import *root=tk () hao=[' Confucianism ', ' Release ', ' Tao ']for each in
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.