tkinter

Setting tkinter to always be the current active window

梦想与她 提交于 2021-01-29 22:19:53
问题 I'm trying to use tkinter as a way to toggle an automation process. The snippet I have below works, but the hotkeys will only work when the tkinter window is the current active window. I found this topic discussing how this can be done, but these methods seem to be OS specific and none seem to work for Windows 10. import tkinter as tk class Automate(tk.Frame): __loop__ = None def __init__(self, master): super(Automate, self).__init__(master) # F7 initiates the loop. self.master.bind('<F7>',

How to create zigzag movements in Python?

守給你的承諾、 提交于 2021-01-29 22:14:49
问题 from tkinter import * def move(): global x1, y1, dx, dy, flag, n, z x1, y1 = x1 + dx, y1 + dy if x1 > 360: x1, dx, dy = 360, -15, 5 can1.itemconfig(oval1, fill = "purple") if x1 < 10: x1, dx, dy = 10, 15, 5 can1.itemconfig(oval1, fill = "red") if y1 == 360: x1, dx, dy = 360, -15, -5 can1.itemconfig(oval1, fill = "green") can1.coords(oval1, x1, y1, x1 + 30, y1 + 30) if flag > 0: abl1.after(50, move) def stop(): global flag flag = 0 def start(): global flag if flag == 0: flag = 1 move() ### x1,

Pass values to python script with Tkinter

筅森魡賤 提交于 2021-01-29 22:04:01
问题 So I've written a python script that uses the PIL library to format a png passed to it. I want to make the script more user friendly and after looking around I saw the Tkinter library which seemed perfect. Basically the script has five variables that I need to pass to it for it to run. I'm currently using the raw_input() function to asking the user for the following variables: path_to_png title subtitle source sample_size Once received the script runs and exports the formatted png. I've used

How to change height of only one row in a Treeview?

不羁的心 提交于 2021-01-29 21:57:57
问题 I'm creating a Tkinter-based GUI in Python, and I can't find out how to change the height of only one row. I've tried this code, but it changes height of every row. from tkinter import * from tkinter.ttk import * root = Tk() Style(root).configure("Treeview", rowheight=40) tree = Treeview(root, style="Treeview") tree.pack() for i in range(100): tree.insert("", END, i, text=str(i) * i) root.mainloop() I've also tried to use the style for certain tags, but it doesn't work. How can I do what I

How to run two parallel scripts from tkinter?

丶灬走出姿态 提交于 2021-01-29 21:25:47
问题 With this code I was able to create a TK Inter pop-up with a button to run a Sample_Function . This Sample_Function destroys the tk pop-up, runs another python file, and then opens itself (the first pop-up) again. How can I run the other_python_file and pop-up 'itself' at the same time — so I can be able to trigger many functions before each one gets completed? import sys, os from tkinter import * import tkinter as tk root = Tk() def Sample_Function(): root.destroy() sys.path.insert(0,'C:

Why the canvas widget into Tkinter with Python 3 is slow?

拥有回忆 提交于 2021-01-29 21:01:51
问题 I've just started to use the Tkinter module with Python(3.2), so I decided to rewrite my old program(I used curses module) with this module. The program is a Game of Life simulator. The algorithm I've implemented works so quickly without the user interface. This is my program(it is a fast experiment, I never used the canvas widget): #!/usr/bin/python3 import gol import Tkinter as tk class Application(tk.Frame): def __init__(self): self.root = tk.Tk() self.root.wm_title('Canvas Experiments')

Concurrent.futures opens new windows in tkinter instead of running the function

心已入冬 提交于 2021-01-29 20:40:47
问题 I am trying to run a function concurrently over multiple files in a gui using tkinter and concurrent.futures Outside of the GUI, this script works fine. However, whenever I translate it over into the GUI script, instead of running the function in parallel, the script opens up 5 new gui tkinter windows (the number of windows it opens is equal to the number of processors I allow the program to use). Ive looked over the code thoroughly and just cant understand why it is opening new windows as

text doesn't contain any characters tagged with “sel” tkinter

别等时光非礼了梦想. 提交于 2021-01-29 20:02:01
问题 I recently read on of the answers written by respected Bryan Oakley(Tkinter adding line number to text widget) where he showed a sample code about solving the problem. When I tried working on that code & it worked correctly till I copy or paste something, i.e. I press Ctrl+C or Ctrl+V . It closed the tkinter window with the following error: _tkinter.TclError: text doesn't contain any characters tagged with "sel" Here is the code: import tkinter as tk class TextLineNumbers(tk.Canvas): def _

Scrollbar in python tkinter Toplevel() shows up but does not scroll

那年仲夏 提交于 2021-01-29 19:24:07
问题 I have looked through all the answered questions available here but to no avail. I'm working on Mac OS X High Sierra and my Scrollbar widget shows up but doesn't scroll the window, any advice? from tkinter import * root = Tk() root.geometry('400x500') root.resizable(False, False) def window(): popup = Toplevel() vertScrollbar = Scrollbar(popup, orient='vertical') vertScrollbar.pack(side='right', fill='y') scrollCanvas = Canvas(popup, width='400', height='500', yscrollcommand=vertScrollbar.set

textract failed with exit code 127: pdftotext on windows 10

杀马特。学长 韩版系。学妹 提交于 2021-01-29 18:21:56
问题 I am trying to run a python program on a windows 10 machine with which I am trying to read and convert PDF files. However every time I run the program I get the following error. I have not found out how to resolve this yet. Is there anyone who can help me please :) Exception in Tkinter callback Traceback (most recent call last): File "C:\Users\trpfinance\AppData\Local\Programs\Python\Python38-32\lib\site-packages\textract\parsers\utils.py", line 82, in run pipe = subprocess.Popen( File "C: