Python Forum

Full Version: Loading a GUI from Terminal
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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?
we would need to see the code
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.
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()