Python Forum
GUI created in Tkinter does NOT show up
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
GUI created in Tkinter does NOT show up
#1
Hello, I've just joined this forum and and I hope I can be usefull in the near future. I have always been autodidact in the programming area, starting many years ago with Fortran IV, Pascal, DbaseIV. Currently I have a very respectable level in developing solutions and applications in VBA for both MS Excel and MS Access.
Currently I am trying to replicate an application in MS Access in open-code platforms and languages. Specifically, MySql and Python.

Well, let's go to the point. I use Visual Studio Code as my editor. And I am just starting in learning Tkinter for developing the GUI's necesary for my application.

I've written the simpliest code possible as a starting point:

import tkinter as tk
ventana=tk.Tk()
ventana.geometry("400x300")
ventana.title("Mi primera Ventana")
ventana.mainloop
The problem is:
1.- After using the RunCode command, the program is executed with no errors, but the window created does NOT show up.
2.- I checked in the terminal and both, Python and Tkinter are correctly installed and the versions are Python 3.13.2 and Tcl/Tk 8.6.15
3.- In fact after entering the command 'python -m tkinter' on the terminal's command line, the test window succesfully appears.
4.- I have searched on the internet; Google, Youtube etc. with no results

Any orientation will be very much appreciated
Reply
#2
You need to call mainloop:

ventana.mainloop()
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
Change ventana.mainloop to ventana.mainloop().

Without the parenthesis, you do not call the function, but it's still valid code.
This is why there is no exception. The mainloop is not called, which is a blocking function.
Then the program just ends.
RCasanuevaU likes this post
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
Reply
#4
Thank you very much. I added the "()" and worked. It is embarrassing having not noticed the mistake before. Apprediated !!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [Tkinter] How to get the result of a ping to show in tkinter? jacklee26 6 9,677 Feb-10-2023, 01:12 PM
Last Post: NebularNerd
  [Tkinter] Tkinter newly created button does not execute command ChipsSlave 7 7,991 Jul-25-2018, 01:01 AM
Last Post: JUANCARLOS
  [Tkinter] How to show and hide tkinter entry box when select yes from drop down Prince_Bhatia 1 11,441 Jun-12-2018, 08:05 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020