Python Forum
[Tkinter] Loading a GUI from Terminal
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] Loading a GUI from Terminal
#1
So I am making a simple program to read the value from an ADS1x15 ADC, convert it to the voltage value that went into it using linear interpolation and then outputting the result to a label upon button press. However, I have to load my script from the terminal window because otherwise the ADS1x15 library is not discoverable via Python 2 or Python 3. Anyways, my program runs no errors but the GUI will not display. I tried running just the Tkinter GUI in the terminal and it doesn't pop up. I can't post the script currently because I'm at a location where the pi is not allowed access to the network. Has anyone else had this issue?

The GUI loads fine if I run it in Python 3, also without the ADS1x15 functions. Only Python 2 and Terminal the GUI does not load. Perhaps the syntax is wrong on my widget commands, but wouldn't that give me an error prompt?
Reply
#2
we would need to see the code
Recommended Tutorials:
Reply
#3
Lets say I try something extremely rudimentary, like creating a frame.
from Tkinter import*
import Tkinter as tk
root = tk.Tk()
root.title('Test')
root.geometry('800x480')
Even running this simple script in python 2 or the terminal nothing will appear on the screen as in python 3. The module will execute error free but no display. I am VERY new to programming as a whole so please excuse me if I'm missing something painfully obvious.
Reply
#4
You have to run the mainloop.
# Python 2
import Tkinter as tk

root = tk.Tk()
root.title('Test')
root.geometry('800x480')
root.mainloop()
# Python 3
import tkinter as tk

root = tk.Tk()
root.title('Test')
root.geometry('800x480')
root.mainloop()
Reply


Forum Jump:

User Panel Messages

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