Beginner python tkinter, use the current learning to write a simple calculator to practice.Expected effect:1. Ability to implement subtraction operations,2. Only numbers can be entered3. Choose which operation to perform with the button.4. Result box cannot be modified, smart copy5. Press the Clear button to clear all contentFROMNBSP;NBSP;TKINTERNBSP;IMPORTNBSP;*COUNTNBSP;=NBSP;TK () count.title ("Pure mash
Code#Tkinter Base Add a button, display text on the button, and set the text colorImportTkinter as TK#Object-Oriented programmingclassApp ():def __init__(self, Master): Frame= Tk. Frame (Master)#frame?? I don't understand .Frame.pack ()#Create a button, FG foreground color: BlueSelf.testbutton = Tk. Button (frame, Text ="Hello", FG ="Blue") self.testButton.pack () root=tk. Tk () app=App (Root) root.mainloop ()Results:
() function allows you to control the scroll bar, 1 for the entire scroll bar, such as you want him to scroll to half of the position you have to write Yview_moveto (0.5), and so on can use the loop to control it in different positions, notice a place,Here, it must be Mylist.yview_moveto (), because you are already using MyList to bind the scroll bar, if you use another control to bind the scrollbar, is the "control name. Yview_moveto", and then, when you debug, you will find that If no update
Drop ~ Today.
Before touching a bit of tkinter, GUI programming a little interest, so on their own thinking to write a small program (haha, too small can not be small program). Well, after all, it's all about the automated tests, so it's a matter of having an automated test. In last week's blogger's notes, there was a solution to the validation code encountered when writing an automated logon script.
Before we mentioned four solutions, let's review:
You want to make a simple Python script editor where the text input Code section is implemented using the text control in Tkinter.But the question is, how do you achieve highlighting? Refer to Python's own editor: code in the Python27/vidle folder.The implementation effect Is:One of the main ideas is that in text every input line of code, all through regular matching, to find whether it is necessary to highlight the effect, the reason is very simple,
This paper is mainly based on colorsys implementation, the sample is from HLS to RGB, if you want to change the color space is very easy to modify only a function, the specific content is as follows
Scale and canvas components are used.
Run:
The code is as follows:
from Tkinter import * Import Colorsys #操作后的响应函数 def update (* args): ' color ' r,g,b = Colorsys.hl S_to_rgb (H.get ()/255.0, L.get ()/255.0, S.get ()/255.0) R,g,b = R * 255, G * 255, B *
The module ("Tk interface") isInterface of the standard Tk GUI toolkit. Tk andIt can be used on most Unix platforms,
It can also be applied in Windows and Macintosh systems. Later versions of Tk8.0 can implement local window styles and run well on most platforms.
Is a Python module with Tk interfaces,Library provides interfaces for Tk APIs,
It belongs to the GUI tool group of Tcl/Tk. Tcl/Tk is a writing and graphics device developed by John Ousterh
-selected button state
Scale
A range control that displays a numeric scale that is a range of numbers for the output limit
Scrollbar
A scrollbar control that is used when the content exceeds a visual area, such as a list box ...
Text
Text control; for displaying multiple lines of text
TopLevel
A container control that provides a separate dialog box, similar to a frame
Spinbox
Input controls, similar to
Python class details and simple examples, python detailed examples
Python
Class
1. A class is a data structure that can be used to create an instance. (In general, classes encapsulate data and methods that can be used for this data)
2. the
Examples of closure usage in python and examples of python usage
This example describes the closure usage in python. Share it with you for your reference. The specific analysis is as follows:
What is a closure?
To put it simply, closures get different results based on differ
Python crawler regular expression skills and examples of crawling personal blogs, python examples
This blog is about regular expression crawler in Data Mining and analysis. It mainly introduces Python Regular Expression crawler and describes common regular expression analysi
Detailed explanations of Python programming sequence operation examples and python programming examples
This article describes the sequence operations of Python programming. We will share this with you for your reference. The details are as follows:
# Coding = utf8''' the se
Python Stack Algorithm Implementation and simple application examples, python algorithm examples
This article describes the implementation and simple application of the Python stack algorithm. We will share this with you for your reference. The details are as follows:
Princi
Examples of common python Regular Expressions and python examples
The following lists the matching usage of Python Regular Expressions:In addition, everything about regular expressions http://deerchao.net/tutorials/regex/regex.htm
1. test whether the regular expression match
Introduction to binary search algorithms and related Python implementation examples, python examples
Binary Search idea:When an ordered table is used to represent a static search table, the search function can be implemented using binary search.In Binary Search, the interval of the record to be queried is determined fi
Examples of python function decorator usage and python function examples
This document describes how to use the python function decorator. Share it with you for your reference. The details are as follows:
The decorator is often used in scenarios with cut-plane requirements.
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.