tk

Tkinter's overrideredirect prevents certain events in Mac and Linux

混江龙づ霸主 提交于 2019-11-30 07:27:20
问题 I am writing a program in Python with a Tkinter UI. I want to have a small window with no title bar. This window must receive keyboard input. I am not picky whether this is in the form of an Entry widget or just binding to KeyPress. overrideredirect(True) is typically how the title bar is disabled. Unfortunately, (except in Windows), this seems to prevent many events from being received. I wrote this code to illustrate the problem: #!/usr/bin/env python from __future__ import print_function

PDF Viewer for Python Tkinter

二次信任 提交于 2019-11-30 05:17:23
问题 I am currently looking for a possibility to display PDF Files inside a Tkinter application (displaying them e.g. in a Frame widget or similar). Is there already a solution for this problem? I already searched SO, used ddg an others but did not find anything for that purpose. Only thing I found was how to print the contents of a tk.Canvas to PDF - is there a way to load a PDF into a Canvas? 回答1: Finally I came to a solution I can work with. Using pypdfocr and its pypdfocr_gs library I call

Inertial scrolling in Mac OS X with Tkinter and Python

為{幸葍}努か 提交于 2019-11-30 01:52:04
问题 I am working on a Python 3.3 project that uses Tkinter as a Window manager. I have mouse scroll wheel events set up for a canvas. The scrolling works in Windows 7, 8, and Ubuntu, but upon scrolling with a Magic Mouse in Mac OS X Mountain Lion, the program crashes with teh following error in the Tk main loop: File "/Users/xxxx/Documents/Repositories/tycoon/agentsim.py", line 291, in start self._root.mainloop() File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/tkinter/__init

How to use default bindtag behavior as methods?

吃可爱长大的小学妹 提交于 2019-11-29 18:21:43
I am trying to invoke default widget behavior on demand. Based on this answer I know a bit about bindtags, and taglists. Let's say for example I have two buttons, and I want to have the bindtag behavior of a specific item in its taglist, of first button, whenever I left click on the right button: import tkinter as tk root = tk.Tk() first_btn = tk.Button(root, text="1st") second_btn = tk.Button(root, text="2nd") second_btn.bind("<Button-1>", "expect the bindtag operation here") first_btn.pack() second_btn.pack() root.mainloop() I haven't specified command=... for first_btn as I need to have the

how to use Tcl/Tk bind function on Tkinter's widgets in Python?

泄露秘密 提交于 2019-11-29 16:14:30
Although Tkinter's derived from Tcl/Tk but it's not as complete as Tcl/Tk. Tcl/Tk bind function has some attributes which tkinter doesn't (e.g. %d that returns The detail field from the event https://www.tcl.tk/man/tcl8.4/TkCmd/bind.htm#M24 ). Tcl/Tk scripts can be used by "eval" function in python but i don't know how to declare a tkinter widget in Tcl/Tk script. so how can i use this function and its attributes on Tkinter widget? Bryan Oakley If you are asking how to create a binding that makes use of the "data" field (ie: %d substitution), you will have to call some tcl code to make that

Why do Tkinter's Radio Buttons all Start Selected When Using StringVar but not IntVar?

左心房为你撑大大i 提交于 2019-11-29 15:29:15
问题 Here is some example code that creates 4 radio buttons, 2 using int and 2 using str : from tkinter import * class test: def __init__(self): wind = Tk() frame1 = Frame(wind) frame1.pack() self.v1 = IntVar() self.v2 = StringVar() int1 = Radiobutton(frame1, text = 'int1', variable = self.v1, value = 1, command = self.ipress) int2 = Radiobutton(frame1, text = 'int2', variable = self.v1, value = 2, command = self.ipress) str1 = Radiobutton(frame1, text = 'str1', variable = self.v2, value = '1',

Python tkinter - 第10章 文本控件(Text)方法

大兔子大兔子 提交于 2019-11-29 14:06:45
10.3 方法 方法 描述 bbox(index) 计算指定字符串的矩形边界。 Index 字符串标识索引 返回值: 一个(x,y,width,height)的四元组。或者None,如果字符串不可见 compare(index1, op, index2) 比较两个索引的大小。比较方法是:“<”, “<=”, “==”, “>=”, “>”, or “!=”。 根据比较结果返回True或者False。 count(index1, index2, *args) 统计标识index1和index2之间的字符数、行数等信息。args包括:-chars, -displaychars, -displayindices, -displaylines, -indices, -lines, -update, -xpixels, -ypixels debug(boolean=None) 设置文本控件内部B-Tree一致性检查的开关 delete(first, last=None) 删除选中的文本。起始是first,last如果没有定义,则只删除当前字符。 dlineinfo(index) 计算包含有指定字符串的矩形范围。这个方法只有在文本控件刷新时才有效。 返回值:一个五元数组(x,y,width,height,baseline)。 x,y:窗口坐标 width,height:矩形的大小 dump

RVM Ruby with TK installation (OSX)

*爱你&永不变心* 提交于 2019-11-29 12:21:48
I'm trying to install Ruby with TK support. Using RVM, I did this: rvm install 1.9.2 -C --enable-shared --enable-pthread The installation appears to work fine, and I can see something called .rvm/src/ruby-1.9.2-p320/ext/tk/tcltklib.c which I assume is the library I need? I then try to run require 'tk' in irb, but get the error message LoadError: no such file to load -- tk Any ideas? Update: Fixed! If anyone is interested in the complete list of steps for a Ruby upgrade to 2.0.0 with TK support on OSX, this is what I did: Install RVM for Ruby - \curl -#L https://get.rvm.io | bash -s stable -

Get data out of a tcltk function

ぐ巨炮叔叔 提交于 2019-11-29 10:54:37
This is probably so simple I will cringe when the answer comes back but I am totally stumped. I have tried the manuals, tried searching the web, assorted examples and anything else I can think of. I am still stuck. I am trying to create a simple input for the user to add two values I can then use in the rest of the R script. I need the script to pause and wait for the input from the user and then continue along once it gets the input (like how the choose file function works). AFter reading a bunch of stuff I decided to use library(tcltk). I have a nice little box within a function. inputs <-

修改lua的代码解析

ε祈祈猫儿з 提交于 2019-11-29 10:44:27
有时候希望在lua中加入自定义风格的代码,例如将某个经常用的函数简化为一个符号,在开发某个GAL引擎时,因为需要大量的用到回显文字的命令,所以希望将该命令简化,可以极大地提升写脚本的效率.例如: //原有脚本实现 echo("这真是一个糟糕的事情","人物1"); echo("这真是一个糟糕的事情","人物2"); echo("这真是一个糟糕的事情","人物3"); echo("这真是一个糟糕的事情","人物4"); ... //修改后的实现 @人物1:"这真是一个不错的事情" @人物2:"这真是一个不错的事情" @人物3:"这真是一个不错的事情" @人物4:"这真是一个不错的事情" ... 这看起来是一件不错的事,^_^想象一下一个文字游戏,基本上都是文字回显的命令,简化后的效率提升不言而喻. 当然,这就要拿lua(遵循GPL协议)的源码开刀,lua的脚本解析主要 在llex.c文件中,通过分析每个字符,提取出关键字,符号,变量等传递给 lparser.c检查语法. 而在 llex.c中最主要的函数是static int llex (LexState *ls, SemInfo *seminfo),该函数负责分割并解析每个WORD,然后返回给语法检查器,我们需要在这里动手将lua中没有定义的符号@解析为echo命令并将两个参数返回. //翻译并传递echo命令 char *str