Articles of tkinter

Python版本和Tcl / Tk兼容性

我已经安装了Tcl和Tk,并且正在运行一个非常熟悉的“No module named _tkinter”错误。 我的“python”Bash命令运行Python版本2.4.2,但Synaptic说我已经安装了2.6.6。 我甚至尝试安装3.0,但也失败了。 我自己configuration​​并构build了Tcl / Tk tarball,并尝试使用突触包。 “wish”和“tclsh”命令都可以工作,所以我知道这些模块已经安装好了,但是我不能让Python认出它们。 此外,我不能为我的数字生活,我应该使用哪个版本的Python,以及如何让我的Bash命令使用该版本。 我没有看到2.4.2删除的任何选项,如果我删除2.6.6,它删除了似乎是我的其他包(夸张,我知道)的大部分。 我真的不知道该从哪里出发,所以任何指导都将不胜感激。 更新: 我不得不重新安装python-tk包,2.6能够导入它。 现在我只需要弄清楚如何删除2.4,以免后来搞砸了。

Linux Mint Tkinter透明窗口

我想要使​​用Tkinter有一个透明的背景: from Tkinter import * root = Tk() root.attributes('-alpha', 0.1) #~ root.wm_attributes('-alpha', 0.1) #~ root.wm_attributes("-transparentcolor", "white") #~ root.attributes("-fullscreen",True) root.mainloop() 此代码在Windows中正常工作,但不使用Linux Mint Maya。 注释掉了我尝试过的其他选项。 任何build议可能是错误的?

尝试在我的Tkinter / Python应用程序中embedded一个本地WINDOWS命令行

我已经做了一些研究,并且使用了不同的graphics工具包,并想知道是否有方法在我的应用程序中显示本地Windows命令行。 所以,它就像Jetbrains产品中的命令行(我认为eclipse也有一个),但是目标是有4个。 我发现了一个Linux软件,演示了我想要做的核心概念,并将其附加在底部。 基本上,我只是想要四个terminal,我要让应用程序处理“易于访问”任务的特定键绑定。 我之前用过这个链接的软件,喜欢它,但是我想当我在探索python的时候,为Windows写这样的东西也是一个很好的学习经验! 提前致谢! 编辑 – 谷歌search“Windows的Tkinter命令行”和喜欢没有收获:)我保证在发布之前我GOOGLE了很多。

Tkinter窗口在embedded式python中没有反应

我已经在dll(Windows 7)中embeddedpython解释器(2.7.6),作为插件加载在本地主机程序,它有自己的用户界面。 Python脚本文件由dll执行,脚本文件stderr被redirect到一个文件,另一个脚本被导入。 在这个脚本中(下面的代码)是一个创buildTkinter窗口的类,并且具有写入Tkinter文本窗口部件的write()方法。 Stdout被这个类redirect到它自己。 该类在线程中运行。 下面的代码在非embedded式python导入时效果很好。 当导入到embedded式python时,窗口出现,并显示输出,无论何时打印到标准输出,但否则窗口无响应(没有响应)。 斯德哥尔德是空的。 import time import threading from Tkinter import * from ScrolledText import * class OutputWindow(threading.Thread): '''Output window where stdout is re-directed. Inherits Thread''' def __init__(self): self.autoScroll = True #root self.root = Tk() self.root.title("My output window") Grid.rowconfigure(self.root, 0, weight = 0) Grid.rowconfigure(self.root, 1, weight = 1) Grid.columnconfigure(self.root, 0, […]

如何禁止与Python的Windows文件处理?

我使用Python 2.7和Tkinter在Windows中运行控制台应用程序。 我正在使用文件浏览器来select文件。 我的问题是,在用户select文件和使用该path的脚本之间,Windows也尝试打开它。 在这种情况下,这是一个.pages文件,它试图用Word打开它。 我不想要这样的事情发生。 我怎样才能阻止它> 只是为了上下文,这是代码: from Tkinter import * from tkFileDialog import * import os.path import shutil import sys import tempfile from zipfile import ZipFile import subprocess class uiclass(): def __init__(self,root): b = Button(root, text="Browse", command=self.callback) w = Label(root, text="Please choose a .pages file to convert.") w.pack() b.pack() def callback(self): print "click!" […]

获取命令窗口输出显示在小部件与tkinter

快速工程摘要 :使用Tkinter制作一个python小部件,显示来自多个json和txt文件的数据。 需要在Windows中工作。 我在哪里 :一切都很好,与JSON文件。 但是我遇到了txt文件的麻烦。 我可以用这段代码parsing出我需要的信息: from Tkinter import * import re results = open("sample_results.txt", "r") for line in results: if re.match("(.*)test(.*)", line): print line if re.match("(.*)number(.*)", line): print line if re.match("(.*)status(.*)", line): print line if re.match("(.*)length(.*)", line): print line 问题 :它显示命令shell中的所有数据而不是单独的小部件。 我想简单地将所有这些信息从命令shell移动到文本框小部件(或者一个tkmessage小部件,但我觉得文本框会更合适)。 一个非常长的谷歌search过程给了我很多代码不起作用 – 任何提示? 谢谢! 注:这不是所有的代码 – 只是我需要帮助修复的部分

尾巴 – 包“python3-tk”没有安装候选人

我目前正在尝试不同的Linux发行版,并试图让我的一些应用程序在最新的Tails发行版上运行。 为此,我需要Python3的tkinter库。 可悲的是,在python3中导入tkinter不起作用,并试图通过 sudo apt-get install python3-tk 给出以下结果: Reading package lists… Done Building dependecy tree Reading state information… Done Package python3-tk is not available, but is referred to by another package. This may mean that the package is missing, has been obsoleted, or is only available from another source E: package 'python3-tk' has no installation […]

在Linux上使用多处理时,不会显示TKinter窗口

我想生成另一个进程asynchronous显示错误消息,而应用程序的其余部分继续。 我正在使用Python 2.6中的multiprocessing模块来创build该进程,我试图用TKinter显示窗口。 这段代码在Windows上工作正常,但在Linux上运行,如果我打电话'showerror("MyApp Error", "Something bad happened.")' TKinter窗口不会出现。 它确实出现,如果我通过直接调用showerrorprocess在同一进程中运行它。 鉴于此, TKinter似乎正在正常工作。 我可以打印到控制台,并从multiprocessing进程产生的进程做其他事情,所以它似乎也工作。 他们似乎并不一起工作。 我是否需要做一些特殊的事情来允许产生的subprocess创build窗口? from multiprocessing import Process from Tkinter import Tk, Text, END, BOTH, DISABLED import sys import traceback def showerrorprocess(title,text): """Pop up a window with the given title and text. The text will be selectable (so you can copy it to the […]

python 3.3中的BadIDChoice RENDER和X上显示的tk / tcl

我有一个相当复杂的GUI,通过在linux上运行的python tkinter编写,其中一个组件(其中有一个经常更新的Text小部件)导致GUI很less崩溃(一天一次)。 guis被显示给在Mac OSX上通过X11和Gnome 2.28.2运行的X,具有相同的行为。 我的Python版本是3.3和tk / tcl版本是8.5。 我得到的错误是: X Error of failed request: BadIDChoice (invalid resource ID chosen for this connection) Major opcode of failed request: 148 (RENDER) Minor opcode of failed request: 4 (RenderCreatePicture) Resource id in failed request: 0x116517f Serial number of failed request: 15106831 Current serial number in output stream: 15106872 […]

Tkinter的overrideredirect可以防止Mac和Linux中的某些事件

我正在用Tkinter UI编写Python程序。 我想有一个没有标题栏的小窗口。 该窗口必须接收键盘input。 我不挑剔这是否是一个Entry小部件的forms,或者只是绑定到KeyPress。 overrideredirect(True)通常是标题栏被禁用的方式。 不幸的是,(除了在Windows中),这似乎阻止了许多事件被接收。 我写这个代码来说明这个问题: #!/usr/bin/env python from __future__ import print_function import Tkinter class AppWindow(Tkinter.Tk): def __init__(self, *args, **kwargs): Tkinter.Tk.__init__(self, *args, **kwargs) self.overrideredirect(True) self.geometry("400×25+100+300") titleBar = Tkinter.Frame(self) titleBar.pack(expand = 1, fill = Tkinter.BOTH) closeButton = Tkinter.Label(titleBar, text = "x") closeButton.pack(side = Tkinter.RIGHT) closeButton.bind("<Button-1>", lambda event: self.destroy()) self.bind("<KeyPress>", lambda event: print("<KeyPress %s>" % […]