Difference between revisions of "Using Tkinter and Other Graphical Applications on Bowie"

From Earlham CS Department
Jump to navigation Jump to search
(Personal Machine)
(Graphical Applications pre-installed on the CS servers)
Line 63: Line 63:
 
You can run the same test code as stated above.
 
You can run the same test code as stated above.
  
= Graphical Applications pre-installed on the CS servers =
+
= Graphical Applications already installed on the CS servers =
 
Along with tkinter pygame is also pre-installed on the CS servers aswell. 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.
 
Along with tkinter pygame is also pre-installed on the CS servers aswell. 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.

Revision as of 16:33, 21 April 2021

Please Disregard Information on this Page, it is still under construction and will be completed soon!!!!

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

  1. 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.
  2. Open the Tkinter terminal and type: xhost + (this relaxes the security of your system and ready it for X11 forwarding).
  3. SSH onto Bowie(tools) with the -Y option (this will establish the X11 connection): ssh -Y <username>@bowie.cs.earlham.edu.
  4. 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
  5. Create your python script. Do not name your script "tkinter.py".
  6. 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()</poem>

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:

  1. As in the previous section ensure Xquartz is installed on your machine.
  2. 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.
  3. Create your python script. Do not name your script "tkinter.py"
  4. 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:

  1. In your Ubuntu terminal SSH onto bowie(tools) with the -Y option: ssh -Y <username>@bowie.cs.earlham.edu
  2. 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
  3. Create your python script do not name your script "tkinter.py"
  4. 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

  1. 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.
  2. Create your python script do not name your script "tkinter.py"
  3. At the top of the script type from Tkinter import *.

You can run the same test code as stated above.

Graphical Applications already installed on the CS servers

Along with tkinter pygame is also pre-installed on the CS servers aswell. 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.