Tkinter Gui does not appear - python

I'm trying to learning Python following a video Tutorial found on You Tube.
The version of Python is 2.6.4 and the OS is Windows 10 64.bit.
Yesterday the tutorial face the creation of GUI.
The miminum instracion set is in a file:
from Tkinter import *
top = Tk()
Running this file in the Python shell of Windows a little window appares.
Yestreday all was running correctly.
The tutorial adds labels and button.
Today I restarted but running the same example the window does not apper.
Could you help me to understand what is wrong?
Ther are some process open?
I have to to some kind of restet.
Thank you

You forgot to start the Tkinter GUI. You should add .mainloop() for that. So:
from Tkinter import *
top = Tk()
top.mainloop()

Related

Why does the same script (GUI) look so different on other Computer ? (customtkinter)

So i wrote a program on one Laptop, but now I bought a new one and wanted to run the same code on my new Laptop and it looks sooo different. I am using a Framework called customtkinter to make the GUI. The Python and the Ubuntu Version on both Laptops are the same, everything updated and upgraded. My new Laptop has a resolution of 3000x2000 and my old was 1920x1080 but that cant be the case even if I increase the dimensions in my Script this wont work. The versions of the libaries i am using are the same as they where on my old laptop. Please help!
import tkinter
from tkinter import ttk
import customtkinter
from customtkinter import *
import datetime as dt
from datetime import datetime
customtkinter.set_appearance_mode("Dark")
customtkinter.set_default_color_theme("dark-blue")
class App(customtkinter.CTk):
def __init__(self):
# Window config
root = CTk()
root.title("Kassa System")
root.geometry(f"{1920}x{1080}")
root.resizable(False,False)
root.mainloop()
if __name__ == "__main__":
app = App()
app.mainloop()
enter image description here
The old one, this is what it should look like
This is how it looks like on the new Laptop:
enter image description here
i tried reinstalling the libaries and changing the python interpreteur.
I provided a bit of the code.
Thanks to #acw1668 i managed to solve the problem. It was a scaling problem. Thank you very much for helping me!

Is there a way to define a name for a python application using tkinter?

So I created an application in Python, and I used the tkinter python library in it using
from tkinter import *
from tkinter.ttk import *
and I had no problems with that, but the application name ended up being Tk. I'm not sure if this was set by default, or just my IDE (vs code) guessing the application name based on the fact that I'm using the tkinter python library in it. I've been looking around to try and find a way to change the application name using tkinter, but I haven't found anything yet. Can someone please help me?
You need to give the application a name via root.title
import tkinter as tk
root = tk.Tk()
root.title('Your name')
root.mainloop()

Why does my Tkinter code take too long to run?

I have a code in Python and I am trying to create a UI for it using Tkinter. I just started off using Tkinter, and got the following code :
from Tkinter import *
window = Tk()
window.title("Hello world")
window.mainloop()
I am using Jupyter notebook to run the code and it's been several minutes and the code still hasn't given me an output. What exactly wrong with this? Is it the code or Jupyter Notebook?
Probably is because in the first line "Tkinter" has to be all in lower case.

Python + TKinter + OMXPlayer window on top

I own a raspberry pi 2 and i start learning Python. I would like to do something very basic : the window of my Python program on top of omxplayer window like a notification system.
I have been able to make an "always on top" window with TKinter but when i launch omxplayer my window is no more on top.
I would apreciate some help !
Thanks
Try:
from Tkinter import *
root = Tk()
root.wm_attributes('-topmost', 1)
Source: http://tkinter.unpythonic.net/wiki/always_on_top
My solution is to used Hello_font from the hello_pi examples on the raspberry pi.

Tk open window issue/bug

If I type the following in the interpreter it works like a charm:
from Tkinter import Tk
from tkFileDialog import askopenfilename
Tk().withdraw()
fh = open(askopenfilename(), 'r')
However, if I write/save/run a script with exactly the same commands, though it works (kind of like expected) the open window goes blank and remains on screen (after opening the selected file) and stays on top of everything.
As a result I need to click on the Python icon again in order for the window to close. At one point this stopped happening, but when I ran a script once without the Tk().withdraw() command the problem re-emerged.
I am running OSX Mavericks. If there is no way to fix the bug, is there any command in Python I can implement that closes this window?
See the accepted answer to this question When do I need to call mainloop in a Tkinter application?. You normally need to call Tk.mainloop() to start the event loop processing for Tk. But when you are running in the interactive interpreter, Python calls the Tk event processor for you, otherwise you would not be able to use Tkinter in the interactive interpreter as easily.

Categories

Resources