Articles of tkinter

Python中的Ubuntu系统托盘

对于UBUNTU 9.04,我如何在python的TKINTER系统托盘中放置一个程序(我认为它不是像Linux那样的)。

python加载Windows deault loader

如何在python 3.x中加载默认的加载器 ? 我想要两个,指定的百分比和未知的进展。 以下是Windows 10的屏幕截图: 我希望这是在同一个窗口,可能包含其他内容。 感谢您的帮助!

Windows上的tkFileDialog.askopenfilename()将所有输出redirect到win32trace

我在Windows 10上通过Anaconda运行Python 2.7.13,并试图运行下面的代码 import Tkinter, tkFileDialog root = Tkinter.Tk() root.withdraw() file_path = tkFileDialog.askopenfilename() (来源: https : //stackoverflow.com/a/14119223/1850917 ) 代码本身工作正常,但Redirecting output to win32trace remote collector的消息出现,当我运行最后一个命令,正如它所说,所有输出redirect,所以我无法打印()等。 有没有办法来禁用这种行为?

Tkinter Cxfreeze错误

我正在尝试在Windows中使用我在Linux中开发的python编译exe文件。 该程序在Windows下的python自己的工作,当我使用cxfreeze它完成,并使exe。 但是,当我运行它时,我得到: C:\projects\0802001S\dist>listen.exe Traceback (most recent call last): File "C:\Python26\lib\site-packages\cx_Freeze\initscripts\Console.py", line 27 , in <module> exec code in m.__dict__ File "./listen.py", line 425, in <module> File "C:\Python26\lib\lib-tk\Tkinter.py", line 1643, in __init__ self.tk = _tkinter.create(screenName, baseName, className, interactive, want objects, useTk, sync, use) _tkinter.TclError: Can't find a usable init.tcl in the following directories: C:/projects/0802001S/lib/tcl8.5 C:/projects/0802001S/lib/tcl […]

如何让Windows资源pipe理器以Python中的string的forms返回文件的path?

背景 我正在使用基本的文本编辑器,并需要使用Windows资源pipe理器来获取文件的path。 这是我目前的代码,但它只是打开文件 – 我需要它作为一个string返回path: import subprocess subprocess.Popen(r'explorer /select, "C:\"') 问题(S) 我将如何将它作为一个string返回path? 我将如何使用path来访问特定的文件? 例如,如果我想打开文件myFile ,但它不在我的程序所在的文件夹中,我将如何在不同的文件夹中访问该文件? 对不起模糊! 技术规格 操作系统:Windows 7 语言:Python 2.7.3

如何在Tkinter窗口中打开一个exe文件

我正试图打开像记事本,Photoshop等应用程序。 在Python中的Tkinter窗口中。 我尝试使用os.sytem(),但它独立打开(不在Tkinter窗口内)。 我曾经search了很多关于这个,但没有得到任何解决scheme。 任何forms的帮助将不胜感激。

Python脚本无法读取Popen输出,直到进程完成(在Windows上)

我有一个Python GUI应用程序,使用subprocess.Popen调用调用另一个Python脚本。 我在我的GUI中有一个Tkinter文本框,我想在其中显示子stream程的输出。 在OS X上,此function完美无瑕,但在Windows 7上,输出不会显示在文本框中,直到子stream程完成运行。 我怎样才能让输出在Windows上实时打印? 代码启动subprocess: p = Popen(command, stdout=PIPE, stderr=STDOUT, bufsize=1, close_fds=ON_POSIX) t = Thread(target=read_and_print, args=(p, log_output)) t.daemon = True t.start() 将输出打印到文本框的function。 这是在一个单独的线程中运行,以便GUI在执行subprocess时不会挂起。 def read_and_print(process, textarea): out = process.stdout for line in iter(out.readline, b''): textarea.insert(END, line) textarea.see(END) #this triggers an update of the text area, otherwise it doesn't update textarea.update_idletasks()

Tkinter用{}显示文字

基本系统信息: Windows 7 64位,python 3.4.3 64位,并在PyCharm教育版1.0.1中运行 我编写了一个程序,向用户显示一个窗口,带有一个下拉菜单和一个button(例如接近尾声)。 下拉菜单中有一个用户可以select的自行车ID号列表,然后点击button,文本将显示,告诉用户他们select了哪辆自行车以及骑自行车多less次。 这是代码: 1 from tkinter import * 2 import pandas as pd 3 from tkinter import ttk 4 from collections import OrderedDict 5 6 # read in the sorted bike file 7 data = pd.read_csv('Sorted_Bike_Uses.csv', header=0) 8 9 bike = data['Bike ID'] # put the bike id's into […]

条目validation在特定情况下触发时停止工作

我有我的一个应用程序。 除了一件事以外,它工作正常。 我希望某些标签根据Entry小部件的内容获得不同的背景颜色,并且如果内容匹配,则应删除Entry的内容,以便input更多的数据。 我做了一个具有相同问题的示例应用程序。 #!/usr/bin/env python import re import Tkinter as tk class Frontend: def __init__(self): self.root = tk.Tk() self.frame = tk.Frame(self.root) self.vcmd = (self.frame.register(self.validate), '%P') self.entry = tk.Entry(self.frame, vcmd=self.vcmd, validate='key') self.label1 = tk.Label(self.frame, text='Foo', bg='green') self.label2 = tk.Label(self.frame, text='Bar', bg='green') self.frame.pack() self.entry.pack() self.label1.pack() self.label2.pack() self.entry.focus() def validate(self, inputstring): if re.match(r'^foo$', inputstring): self.label1.config(bg='red') self.entry.delete(0, tk.END) […]

可靠的方式来延迟Python3代码

我有一个Python 3程序,需要20秒的延迟我试过time.sleep(20),但这会导致负载的问题,如程序停止响应的方式,我使用tkinter的方式,做任何一个没有其他的方法做一个延迟或示例代码是否有一种方法,我可以做这个循环?