Difference between revisions of "Using Tkinter and Other Graphical Applications on Bowie"
m (Tjames19 moved page Using Tkinter on Bowie to Using Tkinter and Other Graphical Applications on Bowie: Did not fully represent the information the page offered) |
m |
||
(3 intermediate revisions by one other user not shown) | |||
Line 1: | Line 1: | ||
− | |||
= Overview = | = Overview = | ||
Line 22: | Line 21: | ||
lbl = Label(window, text="Hello") | lbl = Label(window, text="Hello") | ||
lbl.grid(column=0, row=0) | lbl.grid(column=0, row=0) | ||
− | window.mainloop() | + | window.mainloop() |
Run the script using <code>python3 <file-name></code>. A small window should appear on your screen named "Welcome to My Tkinter app" with the text "Hello" written inside the window. | Run the script using <code>python3 <file-name></code>. A small window should appear on your screen named "Welcome to My Tkinter app" with the text "Hello" written inside the window. | ||
Line 63: | Line 62: | ||
You can run the same test code as stated above. | You can run the same test code as stated above. | ||
− | = Graphical Applications | + | = Other Graphical Applications installed on the Servers = |
− | Along with tkinter pygame is also | + | Along with tkinter, pygame is also installed on the CS servers. Despite what graphical application you use the general first 3 steps explained in the "Tkinter for Mac Users" section must be applied for MacOS machines and the first step in the "Tkinter for Windows Users" will apply for those using Windows. |
Please contact the admins if any problem should arise when going through the steps above or for the installation of graphical application software on the CS servers. | Please contact the admins if any problem should arise when going through the steps above or for the installation of graphical application software on the CS servers. | ||
+ | |||
+ | Tested and working 2022 |
Latest revision as of 13:42, 26 November 2022
Contents
Overview
When attempting to run graphical application software on a remote connection i.e. our servers, via an SSH connection one must use the -Y optional. This allows for the use of X11 forwarding, in which is a networking protocol that allows you to launch the display that will be produced by the graphical application on your screen, allowing you to interact with the graphical interface. Without this, you will get an error when running on the CS servers indicating that the application has no screen to forward the display to. Please visit here for more information on X11 forwarding.
Below is an example, of how to use Tkinter, a python GUI package on both the servers and your own machine. Although the steps may vary for your specific application the initial first few steps will still apply when attempting to run any graphical application on the servers.
Tkinter for Mac Users
CS Servers
- Mac requires the use of Xquartz an X server program that manages the graphical connection between you and the remote client. Ensure Xquartz is installed on your machine and open the Xquartz terminal, you will run all the following commands here.To install Xquartz on your machine you may look at the Xquarts website.
- Open the Tkinter terminal and type: xhost + (this relaxes the security of your system and ready it for X11 forwarding).
- SSH onto Bowie(tools) with the -Y option (this will establish the X11 connection): ssh -Y <username>@bowie.cs.earlham.edu.
- Load a python environment, preferably one that is a newer version of python. It is not promised that Tkinter will work for versions below 2.7: module load python/3.9
- Create your python script. Do not name your script "tkinter.py".
- At the top of the script type
from Tkinter import *
.
Below is some test code to ensure everything is working. Create a python file in your terminal type in the script:
from tkinter import * window = Tk() window.title("Welcome to My Tkinter app") lbl = Label(window, text="Hello") lbl.grid(column=0, row=0) window.mainloop()
Run the script using python3 <file-name>
. A small window should appear on your screen named "Welcome to My Tkinter app" with the text "Hello" written inside the window.
Personal Machine
For your personal machine:
- As in the previous section ensure Xquartz is installed on your machine.
- Ensure that python 2.7 or higher is installed on your machine.It is not promised that tkinter will work for versions below 2.7.
- Create your python script. Do not name your script "tkinter.py"
- At the top of the script type
from Tkinter import *
You can run the same test code as stated above.
Tkinter for Windows Users
CS Servers
No other application for Windows is needed you can run the commands below as-is:
- In your Ubuntu terminal SSH onto bowie(tools) with the -Y option:
ssh -Y <username>@bowie.cs.earlham.edu
- Load a python environment, preferably one that is a newer version of python it is not promised that tkinter will work for versions below 2.7:
module load python/3.9
- Create your python script do not name your script "tkinter.py"
- At the top of the script type from tkinter import *
Below is some test code to ensure everything is working. Create a python file in your terminal type in the script and run it: python3 <file name>
from tkinter import * window = Tk() window.title("Welcome to My Tkinter app") lbl = Label(window, text="Hello") lbl.grid(column=0, row=0) window.mainloop()
A small window should appear on your screen named "Welcome to My Tkinter app" with the text "Hello" written inside the window.
Personal Machine
- Load a python environment, preferably one that is a newer version of python. It is not promised that tkinter will work for versions below 2.7.
- Create your python script do not name your script "tkinter.py"
- At the top of the script type
from Tkinter import *
.
You can run the same test code as stated above.
Other Graphical Applications installed on the Servers
Along with tkinter, pygame is also installed on the CS servers. Despite what graphical application you use the general first 3 steps explained in the "Tkinter for Mac Users" section must be applied for MacOS machines and the first step in the "Tkinter for Windows Users" will apply for those using Windows.
Please contact the admins if any problem should arise when going through the steps above or for the installation of graphical application software on the CS servers.
Tested and working 2022