python-tkinter-examples

所属分类:Python编程
开发工具:Python
文件大小:390KB
下载次数:0
上传日期:2018-03-26 13:42:24
上 传 者sh-1993
说明:  使用Python&TKinter的GUI编程示例
(GUI programming examples using Python & TKinter)

文件列表:
.project (377, 2018-03-26)
.pydevproject (302, 2018-03-26)
.settings (0, 2018-03-26)
.settings\org.eclipse.core.resources.prefs (61, 2018-03-26)
LICENSE (35141, 2018-03-26)
circular_tree.png (205375, 2018-03-26)
color_gui.py (7262, 2018-03-26)
color_navbar_test.py (7431, 2018-03-26)
custom_button.py (1943, 2018-03-26)
data (0, 2018-03-26)
data\experiments (0, 2018-03-26)
data\experiments\00000_Example Experiment.yaml (72, 2018-03-26)
data\experiments\00001_Example Experiment 2.yaml (76, 2018-03-26)
data\experiments\00002_Example Experiment 3.yaml (72, 2018-03-26)
data\mydb (169, 2018-03-26)
data\mydb.yaml (169, 2018-03-26)
demopanels.py (3875, 2018-03-26)
draglistbox.py (1483, 2018-03-26)
dragsort_multilist.py (5261, 2018-03-26)
fullscreen_app.py (5886, 2018-03-26)
icon.jpeg (5774, 2018-03-26)
icon.png (10724, 2018-03-26)
icon (0, 2018-03-26)
icon\datasets.gif (2715, 2018-03-26)
icon\datasets.png (25955, 2018-03-26)
icon\experiments.gif (1025, 2018-03-26)
icon\experiments.png (5162, 2018-03-26)
icon\experiments_tiny.png (620, 2018-03-26)
icon\icon.jpeg (5774, 2018-03-26)
icon\icon.png (10724, 2018-03-26)
icon\sessions.gif (2586, 2018-03-26)
icon\sessions.png (21307, 2018-03-26)
icon\videos.gif (914, 2018-03-26)
icon\videos.png (5177, 2018-03-26)
image_test.py (2478, 2018-03-26)
image_test2.py (568, 2018-03-26)
k5.ps (6235, 2018-03-26)
... ...

## tkinter-png ## # Overview # Through use of just standard python modules and pypng this adds support for pngs to tkinter which can be used through the standard PhotoImage? object to be placed onto buttons, labels or a canvas. This project was started in part due to no official build of PIL for python 3.x and also to allow the use of png images in a standard python distribution without the user needing to install anything else, which may prove problematic without root/admin access. # Current Features # - Supports any .png image, regardless of bit depth or presence of an alpha channel. - Has boolean transparency support: fully transparent or opaque, no partial transparency. - Modified tkinter.PhotoImage class supports tcl/tk's transGet, transSet, copy, redither and data methods # Advantages and Disadvantages # The advantages to using this implementation over a more complete library are simple: - No installation needed: everything (including pypng) are just .py files that can be dropped into your working directory - Pure python: doesn't need any bindings to C libraries, relying only on python and python-tk. As such it is highly portable and should work on any system that tkinter runs on. - Simple: codebase is small enough for others to understand and expand on. - Extends existing tkinter functionality: several tcl/tk functions regarding the PhotoImage class are not usable in tkinter (such as transGet and transSet) and others which are present have been stripped down (e.g. copy). These functions can be used with non-png PhotoImages too! That being said, there are reasons not to use this module: - Lack of functionality: Compared to a more complete library such as the Python Imaging Library, tkinter-png is very lacking, not even able to rotate images (yet). - Speed: Although it has been optimised several times and is now about 250% faster than it once was, there is no denying that processing images is slow. Even on modern machines, multiple large images can have a huge impact on how long a program takes to load. - Quality: No sense denying it, tkinter-png was hacked together by a complete novice programmer as work to hand in during the 9th week of a 1st-year university course. While this code shouldn't explode your machine or eat your hamster, it's not exactly seen a wide testing grounds yet. # Installation # 1. Download the tkinter-png .zip archive or checkout the source from svn on google code. 2. Copy the tkinter_png.py and png.py files to whatever directory your code will be in. 3. *** 4. Profit! # Usage # Simply import tkinter_png after tkinter. Initialise your image with "var_name = PngImageTk(filename)" This will also create a blank PhotoImage associated with the image at "var_name.image" Use "var_name.covert()" to convert the png so tkinter can use it. The associated PhotoImage will now contain the png. Now you can use your png image in the "var_name.image" PhotoImage like any other image! # Changelog # 0.75 - Added various optimisations (aprox 20% faster) and fixed a bug in PngImageTk.convert with images larger than 550x400 0.7 - Module and example program seperated for clarity and proper usage. 0.6 - Added a moving, bouncing box between two image layers to demonstrate transparency. 0.5 - Boolean transparency added. tcl/tk PhotoImage methods hacked onto tkinter. 0.4 - Optimisation: uses single .put() to place all pixels at once 0.3 - Structure rearranged to use classes and functions for later code re-use. General cleanup. 0.2 - Optimisation: .put() places entire rows instead of pixel by pixel. Huge speed boost. 0.1 - Working concept, extremely slow, uses .put() to place each pixel in the image. Strips alpha channel. 0.01 - No support for images with alpha channel, uses small rectangles to place each pixel. Not released.

近期下载者

相关文件


收藏者