tk

Using Tk with C

我是研究僧i 提交于 2019-12-03 12:06:27
问题 I’m a C programmer with no desire to deal with C++ tool-kits, and I’m trying to build a simple graphical card game. I’m programming under Linux, but I’d like to have the option of a Windows port. From what I’ve read, my options are GTK+ and Tk. I’m working through some GTK+ tutorials, and I’ll probably stick with that, but I don’t think I’m giving Tk a fair shot. Trouble is, all the Tk documentation I can find is either for using Tk with {Tcl, Ruby, Perl, Python}, or for embedding a Tcl

from matplotlib.backends import _tkagg ImportError: cannot import name _tkagg

馋奶兔 提交于 2019-12-03 10:36:50
While trying to run this example to test how matplotlib works with Tkinter, I am getting the error: (env)fieldsofgold@fieldsofgold-VirtualBox:~/new$ python test.py Traceback (most recent call last): File "test.py", line 7, in <module> from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg, NavigationToolbar2TkAgg File "/home/fieldsofgold/new/env/local/lib/python2.7/site-packages/matplotlib/backends/backend_tkagg.py", line 13, in <module> import matplotlib.backends.tkagg as tkagg File "/home/fieldsofgold/new/env/local/lib/python2.7/site-packages/matplotlib/backends/tkagg.py", line 7,

No module named Image tk [closed]

匿名 (未验证) 提交于 2019-12-03 10:24:21
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am new to python can any body please Help D:\python\sub>python app.py Traceback (most recent call last): File "app.py", line 2, in import ImageTk ImportError: No module named ImageTk 回答1: This says that python is installed in non-standard location so the OS can not find ImageTk as it look in standard locations. You can re-install Python in a standard location, and where that is depends on which operating system and which installer you are using, or append this location to sys.path. I'm using Ubuntu 13.04 and I simply install ImageTk

Mysterious behavior of Dictionary&lt;TKey, TSource&gt;

匿名 (未验证) 提交于 2019-12-03 08:41:19
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I'm working on a huge system based on Asp.net MVC 3.0 and working on Mono-2.10.8 (Windows 7). Everything was fine until a moment couple of days ago. Inside my API I have several utility classes using dictionaries. For example, like this one: public static class KeyUtility { static KeyUtility () { Alphabet = new [] { 'A' , 'B' , 'C' , 'D' , 'E' , 'F' , 'G' , 'H' , 'J' , 'K' , 'L' , 'M' , 'N' , 'P' , 'R' , 'S' , 'T' , 'U' , 'V' , 'X' , 'Y' , 'Z' , '0' , '1' , '2' , '3' , '4' , '5' , '6' , '7' , '8' , '9' }; ReverseAlphabet = Alphabet

Removing the TK icon on a Tkinter window

匿名 (未验证) 提交于 2019-12-03 08:39:56
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Does anybody know how to make the icon not show up? I'm looking for a way to have no icon at all. 回答1: On Windows Step One: Create a transparent icon using either an icon editor, or a site like rw-designer . Save it as transparent.ico . Step Two: from tkinter import * tk = Tk() tk.iconbitmap(default='transparent.ico') lab = Label(tk, text='Window with transparent icon.') lab.pack() tk.mainloop() On Unix Something similar, but using an xbm icon. 回答2: Similar to the accepted answer (with the con of being uglier): import tkinter import tempfile

Using Tk with C

旧巷老猫 提交于 2019-12-03 03:33:54
I’m a C programmer with no desire to deal with C++ tool-kits, and I’m trying to build a simple graphical card game. I’m programming under Linux, but I’d like to have the option of a Windows port. From what I’ve read, my options are GTK+ and Tk. I’m working through some GTK+ tutorials, and I’ll probably stick with that, but I don’t think I’m giving Tk a fair shot. Trouble is, all the Tk documentation I can find is either for using Tk with {Tcl, Ruby, Perl, Python}, or for embedding a Tcl interpreter into the C program and using Tk that way. Is there an easy(-ish) way to use Tk to build GUIs for

What does calling Tk() actually do?

北城余情 提交于 2019-12-03 02:51:15
I was brushing up on Tkinter when I looked upon a minimal example from the NMT Tkinter 8.5 Reference . #!/usr/bin/env python import tkinter as tk class Application(tk.Frame): def __init__(self, master=None): tk.Frame.__init__(self, master) self.grid() self.createWidgets() def createWidgets(self): self.quitButton = tk.Button(self, text='Quit',command=self.quit) self.quitButton.grid() app = Application() app.master.title('Sample application') app.mainloop() It's all well and good, until I notice that the Tk class isn't being initialized. In other online reference material I could find ( Python's

In tkinter, why winfo_height() always return 1?

匿名 (未验证) 提交于 2019-12-03 02:16:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: This is the most easy example. #py3 from tkinter import * tk = Tk() canvas = Canvas(tk, width= 500 , height = 400) canvas.winfo_height() #In [4]: canvas.winfo_height() #Out[4]: 1 回答1: You have to pack the canvas element in the window before getting it's height. The height return is the actual height. >>> from tkinter import * >>> tk = Tk() >>> canvas = Canvas(tk, width= 500 , height = 400) >>> canvas.winfo_height() 1 >>> canvas.pack() >>> canvas.winfo_height() 402 回答2: If it doesn't work by using pack() function, you can try to add canvas

TKinter in a Virtualenv

匿名 (未验证) 提交于 2019-12-03 02:14:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Trying to run python code with TKinter-based widgets from a virtualenv. user@computer:~/myproject$ env/bin/python Python 2.7.3 (default, Sep 26 2012, 21:51:14) [GCC 4.7.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import Tkinter Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 42, in <module> raise ImportError, str(msg) + ', please install the python-tk package' ImportError: No module named _tkinter, please install the python-tk

Tkinter: “Python may not be configured for Tk”

匿名 (未验证) 提交于 2019-12-03 02:00:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Today I wanted to start working with Tkinter, but I have some problems. Python 3.2 (r32:88445, Mar 28 2011, 04:14:07) [GCC 4.4.5] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from tkinter import * Traceback (most recent call last): File " ", line 1, in File "/usr/local/lib/python3.2/tkinter/__init__.py", line 39, in import _tkinter # If this fails your Python may not be configured for Tk ImportError: No module named _tkinter So how can I configure my Python 3.2 to work with Tkinter? 回答1: According to