Alq Veers 0 Newbie Poster

Ive been working on this for a while, and still am quite stuck. I've got the menu code done and it causes no problems, but as for organising the screen for the remaining two sections I am still having trouble.

Im using the .grid() setting, and am thinking if I need to pre-align the screen before the buttons and such are created. Or if it should work by just assigning them like I have been.

Now I have two prototype versions of the code. One version I have been stuck on for several weeks, and a new version I am writing again, and re-writing the problem areas from scratch.

v0.55

#
# File: gui_GameScreen_Code_v0.55.pyw
# Programmer: A. Smith
# Created: 20100305

# Edited: 20100317
# Time: 12:09



# ::Goals::
# - Divide windows (top, center, right) for alignment of buttons/controls
# - Include a timer or timer zone for adding with Game Code
# - Bind Menu buttons (Close:Done. Rest:Incomplete) to Event to do its prescripted action
# - Open new detail windows for several Menu buttons when Binded
# - Create new internal window (aligned Center) for game screen
# - 


# ::Notes::
# .windowDivide() and gameWindow() are 2 attempts at the same goal. incomplete.
    # divide into Top (menu), Right (controls) and Center (game screen)
    # Center screen needs to be a child (?), but has to say in main. Not be seperate.
    # Divide window into panes for aspect ratio
# .timerZone() Not complete, ignore until GUI more complete/add in programming phase.
# Place window (Tk) inside Application ?. Allow for instant view resize ?
#
# Completely reorganise this code for child window adaptations.



## ::----:: End Programmer Comments ::----::



## ::----:: Start Code ::----::
## ::----:: Import Libraries ::----::


## Import all from Tkinter to begin GUI
from Tkinter import *
# import time  ## For timer (?)
#import Tkinter as tk  ## To be deleted


## ::----:: End Import ::----::
## ::----:: GUI Game Screen ::----::


## Creating GUI in one class (section)
class Icons(Frame):


    ## ::--:: Create Widget Containers ::--::

    def __init__(self, master=None):

        Frame.__init__(self, master)
        
        ## ::--:: Window Attributes ::--::
        
        self.grid(sticky=N+S+E+W)
       # self.windowDivide() ## Incomplete - see notes.
       # self.gameWindow() ## Incomplete - see notes.

       
       ## ::--:: Menu Bar Icons ::--::
       
        self.fileDrop()
        self.helpDrop()
        self.viewDrop() ## contains simple, immediate screen changes ?
        

        ## ::--:: Game/Control Buttons/Items ::--::

        #self.timerZone() ## Incomeplete - see notes.
        self.startButton()
        self.resetButton()
        self.pauseButton()
        self.stopButton()



    ## ::----:: Widget code/screen structure ::----::
    ## This is where the widgets are coded/placed

        
    ## ::----:: Menu Code ::----::
            
    def fileDrop(self):
            
        self.mb = Menubutton(self, text="File", relief=RIDGE, font=("Arial", 10))
        self.mb.grid(row=0, column=0)
        self.mb.menu = Menu(self.mb, tearoff=1)
        self.mb["menu"] = self.mb.menu
        self.optionVar = IntVar()
        self.closeVar = IntVar()
        self.mb.menu.add_checkbutton(label="Options", variable=self.optionVar)
        self.mb.menu.add_command(label="Close", command=self.quit)


    def helpDrop(self):

        self.mb = Menubutton(self, text="Help", relief=RIDGE, font=("Arial", 10))
        self.mb.grid(row=0, column=1)
        self.mb.menu = Menu(self.mb, tearoff=1)
        self.mb["menu"] = self.mb.menu
        self.helpFileVar = IntVar()
        self.helpWikiVar = IntVar()
        self.creditVar = IntVar()
        self.mb.menu.add_checkbutton(label="Help File", variable=self.helpFileVar)
        self.mb.menu.add_checkbutton(label="Help Wiki", variable=self.helpWikiVar)
        self.mb.menu.add_checkbutton(label="Credits", variable=self.helpWikiVar)


    def viewDrop(self):

        self.mb = Menubutton(self, text="View", relief=RIDGE, font=("Arial", 10))
        self.mb.grid(row=0, column=2)
        self.mb.menu = Menu(self.mb, tearoff=1)
        self.mb["menu"] = self.mb.menu
        self.presetColourVar = IntVar()
        self.gridlinesVar = IntVar()
        self.mb.menu.add_checkbutton(label="Colours", variable=self.presetColourVar)
        self.mb.menu.add_checkbutton(label="Grid Lines", variable=self.gridlinesVar)

    ## ::----:: End Menu Code ::----::     
    ## ::----:: Game Window Code ::----::

    #def windowDivide(self):

      # m1 = PanedWindow():
       # m1.pack(fill=BOTH, expand=1)

       # top = Label(m1, text="top pane")

       

   # def gameWindow(self):

     #   self.gameWin = Toplevel(self, relief=FLAT)
     #   self.gameWin.grid(ipadx=6, ipady=6, sticky=CENTER)
        
        
    ## ::----:: End Game Window Code ::----::        
    ## ::----:: Button Code ::----::

    #def timerZone(self):

     #   curtime = ''
     #   clock = Tkinter.Label()
      #  clock.grid(row=6, column=5)

      #  def tick():
       #     global curtime
      #      newtime - time.strfttime('%H:%M:%S')
      #      if newtime != curtime:
       #         curtime = newtime
      #          clock.config(text=curtime)
      #      clock.after(200, tick)
      #  tick()

       
    def startButton(self):

        top=self.winfo_toplevel()
        top.rowconfigure(0, weight=1)
        top.columnconfigure(0, weight=1)
        self.rowconfigure(2, weight=1)
        self.columnconfigure(10, weight=1)
        self.start = Button(self, text="Start", relief=RAISED, font=("Arial", 10))
        self.start.grid(row=3, column=10, sticky=E)


    def resetButton(self):

        top=self.winfo_toplevel()
        top.rowconfigure(0, weight=1)
        top.columnconfigure(0, weight=1)
        self.rowconfigure(4, weight=1)
        self.columnconfigure(10, weight=1)
        self.reset = Button(self, text="Reset", relief=RAISED, font=("Arial", 10))
        self.reset.grid(row=4, column=10, sticky=E)


    def pauseButton(self):
        
        top=self.winfo_toplevel()
        top.rowconfigure(0, weight=1)
        top.columnconfigure(0, weight=1)
        self.rowconfigure(6, weight=1)
        self.columnconfigure(10, weight=1)
        self.pause = Button(self, text="Pause", relief=RAISED, font=("Arial", 10))
        self.pause.grid(row=5, column=10, sticky=E)


    def stopButton(self):

        top=self.winfo_toplevel()
        top.rowconfigure(0, weight=1)
        top.columnconfigure(0, weight=1)
        self.rowconfigure(8, weight=1)
        self.columnconfigure(10, weight=1)
        self.stop = Button(self, text="Stop", relief=RAISED, font=("Arial", 10))
        self.stop.grid(row=6, column=10, sticky=E)

class gameScreen(Frame):

    def __init__(self, master=None):

        Frame.__init__(self, master)

        self.grid(sticky=N+S)
        
        ## ::--:: Window Attributes ::--::

        self.testButton()


    def testButton(self):
        
        top=self.winfo_toplevel()
        top.rowconfigure(0, weight=1)
        top.columnconfigure(0, weight=1)
        self.rowconfigure(5, weight=1)
        self.columnconfigure(5, weight=1)
        self.tB = Button(self, text="Test Button - Game Screen", relief=RAISED, font=("Arial", 10))
        self.tB.grid(sticky=N+E)


       # self.tB = Button(self, text="Test Button", relief=RAISED, font=("Arial", 10))


    

    ## ::----:: Button Events ::----::
    ## ::--:: Controls ::--::

    #def (self, event):
        #if self.["background"] == "":
        #    self.["background"] = "red"
        #else:
        #    self.()

    ## ::----:: End Events ::----::


## ::----:: End GUI Screen ::----::    
## ::----:: GUI Run Script ::----::

class MainWindow():

    def __init__(self):

        self.root = Tk()
        self.root.title('Major Project - SDD. V.05')
        self.root.geometry('1000x800+140+90')

    def menu_Icons(self):
        Icons()
       # gameScreen()

    def gameView(self):
        gameScreen()
        

mw = MainWindow()
mw.menu_Icons()
mw.gameView()

## This prepares the program and runs it

## Sizes the tK window
#root = tk.Tk()
#root.geometry("1000x800+140+90")

#app = Application()
#app.master.title("Major Project - SDD. V.05")  ## This appears in the title bar
#app.mainloop()

## ::----:: End Run Script ::----::

## ::----:: End Program ::----::

v0.6

#
# File: gui_GameScreen_Code_v0.6.pyw
# Programmer: A. Smith
# Created: 20100305

# Edited: 20100319
# Time: 09:31



# ::Goals::
# - Fix child windows for mainMenu, controlButtons and gameScreen. So they can be
# positioned and aligned.
# - Align buttons within each window.
# - Algin windows


# ::Notes::
# - Libraries : Excludes Error possiblity if file is used in Py3.x instead of Py2.x
#



## ::----:: End Programmer Comments ::----::


## ::----:: Start All Code ::----::
## ::----:: Import Libraries ::----::

try:
    # Python2.x
    from Tkinter import *
except ImportError:
    # Python3.x
    import tkinter as tk

## ::----:: End Import ::----::

## ::----:: GUI Window Main Code::----::



## ::----:: Main Tk Window Class ::----::
class mainMenu(Frame):

    def __init__(self, master=None):

        Frame.__init__(self, master)
        
        self.grid(sticky='nw',row=0, column=0)

    ## ::--:: Drop Menu Icons ::--::
        
        self.fileDrop()
        self.helpDrop()
        self.viewDrop()

    ## ::--:: End Menu Icons ::--::
        
## ::----:: Drop down Menu Code ::----::
    def fileDrop(self):
            
        self.mb = Menubutton(self, text="File", relief=RIDGE, font=("Arial", 10))
        self.mb.grid(row=0, column=0)
        self.mb.menu = Menu(self.mb, tearoff=1)
        self.mb["menu"] = self.mb.menu
        self.optionVar = IntVar()
        self.closeVar = IntVar()
        self.mb.menu.add_checkbutton(label="Options", variable=self.optionVar)
        self.mb.menu.add_command(label="Close", command=self.quit)


    def helpDrop(self):

        self.mb = Menubutton(self, text="Help", relief=RIDGE, font=("Arial", 10))
        self.mb.grid(row=0, column=1)
        self.mb.menu = Menu(self.mb, tearoff=1)
        self.mb["menu"] = self.mb.menu
        self.helpFileVar = IntVar()
        self.helpWikiVar = IntVar()
        self.creditVar = IntVar()
        self.mb.menu.add_checkbutton(label="Help File", variable=self.helpFileVar)
        self.mb.menu.add_checkbutton(label="Help Wiki", variable=self.helpWikiVar)
        self.mb.menu.add_checkbutton(label="Credits", variable=self.helpWikiVar)


    def viewDrop(self):

        self.mb = Menubutton(self, text="View", relief=RIDGE, font=("Arial", 10))
        self.mb.grid(row=0, column=2)
        self.mb.menu = Menu(self.mb, tearoff=1)
        self.mb["menu"] = self.mb.menu
        self.presetColourVar = IntVar()
        self.gridlinesVar = IntVar()
        self.size_normVar = IntVar()
        self.size_oneVar = IntVar()
        self.size_twoVar = IntVar()
        self.size_threeVar = IntVar()
        self.mb.menu.add_checkbutton(label="Colours", variable=self.presetColourVar)
        self.mb.menu.add_checkbutton(label="Grid Lines", variable=self.gridlinesVar)
        self.mb.menu.add_checkbutton(label="Size Norm ", variable=self.size_normVar)
        self.mb.menu.add_checkbutton(label="Size 1 ", variable=self.size_oneVar)
        self.mb.menu.add_checkbutton(label="Size 2 ", variable=self.size_twoVar)
        self.mb.menu.add_checkbutton(label="Size 3 ", variable=self.size_threeVar)

        #return size_oneVar

       # if size_oneVar == self.root.geometry('1000x800+140+90'):
      #      self.root.geomtry('800x800+140+90')
       # elif size_twoVar == self.root.geometry('1000x800+140+90'):
       #     self.root.geometry('1280x768+140+90')
       # elif size_threeVar == self.root.geometry('1000x800+140+90'):
       #     self.root.geometry('1024x768+140+90')
       # else:
        #    self.root.geometry('1000x800+140+90')
## ::----:: End Menu Code ::----::
            
## ::----:: End Main Tk Window Class ::----::


            
## ::----:: Control Buttons Class ::----::
class controlButtons(Frame):

    def __init__(self, master=None):

        Frame.__init__(self, master)

        self.grid(sticky='ne', row=5, column=6)

    ## ::--:: Control Items ::--::

        #self.timerZone() ## Incomeplete - see notes.
        self.startButton()
        self.resetButton()
        self.pauseButton()
        self.stopButton()

    ## ::--:: End Control Buttons/Items ::--::

## ::----:: Control Buttons ::----::
    def startButton(self):

        top=self.winfo_toplevel()
        top.rowconfigure(0, weight=1)
        top.columnconfigure(0, weight=1)
        self.rowconfigure(2, weight=1)
        self.columnconfigure(10, weight=1)
        self.start = Button(self, text="Start", relief=RAISED, font=("Arial", 10))
        self.start.grid(row=2, column=0, sticky=N+E)


    def resetButton(self):

        top=self.winfo_toplevel()
        top.rowconfigure(0, weight=1)
        top.columnconfigure(0, weight=1)
        self.rowconfigure(4, weight=1)
        self.columnconfigure(10, weight=1)
        self.reset = Button(self, text="Reset", relief=RAISED, font=("Arial", 10))
        self.reset.grid(row=4, column=0, sticky=E)


    def pauseButton(self):
        
        top=self.winfo_toplevel()
        top.rowconfigure(0, weight=1)
        top.columnconfigure(0, weight=1)
        self.rowconfigure(6, weight=1)
        self.columnconfigure(10, weight=1)
        self.pause = Button(self, text="Pause", relief=RAISED, font=("Arial", 10))
        self.pause.grid(row=6, column=0, sticky=E)


    def stopButton(self):

        top=self.winfo_toplevel()
        top.rowconfigure(0, weight=1)
        top.columnconfigure(0, weight=1)
        self.rowconfigure(8, weight=1)
        self.columnconfigure(10, weight=1)
        self.stop = Button(self, text="Stop", relief=RAISED, font=("Arial", 10))
        self.stop.grid(row=8, column=0, sticky=S+E)

## ::----:: End Control Buttons ::----::

## ::----:: End Control Buttons Class ::----::



## ::----:: Game Screen Class ::----::
class gameScreen(Frame):

    def __init__(self, master=None):

        Frame.__init__(self, master)

        self.grid()

        self.testButton()

    ## ::--:: Test Button ::--::

    def testButton(self):

        top=self.winfo_toplevel()
        top.rowconfigure(0, weight=1)
        top.columnconfigure(0, weight=1)
        self.rowconfigure(5, weight=1)
        self.columnconfigure(5, weight=1)
        self.tB = Button(self, text="Test Button - Game Screen", relief=RAISED, font=("Arial", 10))
        self.tB.grid(sticky=N+E)

    ## ::--:: End Test Button ::--::

## ::----:: End Game Screen Class ::----::



## ::----:: Parent Tk Window ::----::
class mainTkWindow():

    #def __init__(self):

    #    self.root = Tk()
    #    self.root.title('Major Project - SDD. v0.6')
    #    self.root.geometry('1000x800+140+90')
       
    def menu_Icons(self):
        mainMenu()
       
              
    def gameControl(self):
        controlButtons()
        
    def gameView(self):
        gameScreen()
        
## ::----:: End Parent Tk Window ::----::
## ::----:: Run Program ::----::

root = Tk()
root.title('Major Project - SDD. v0.6')
root.geometry('1000x800+140+90')

mw = mainTkWindow()
mw.menu_Icons()
mw.gameControl()
mw.gameView()


## ::----:: End Run Program ::----::
## ::----:: End GUI Window Main Code::----::

And this is the version I am re-writing.
secondGen_v0.001

#
# File: gui_secondGen_v0.01.pyw
# Programmer: A. Smith
# Created: 20100323

# Edited: 20100420
# Time: 17:03

# Notes:
# 1) Working way down page. Class menu, screen, controls.
#


## ::----:: End Programmer Comments ::----::



## ::----:: Start All Code ::----::
## ::----:: Import Libraries ::----::


try:
    # Python2.x
    from Tkinter import *
except ImportError:
    # Python3.x
    import tkinter as tk


## ::----:: End Import ::----::
## ::----:: GUI Main Code::----::

   
class controlMenu(Frame):

    def __init__(self, master=None):
        Frame.__init__(self, master, bg='yellow')

        self.grid(row=0, column=0)

    ## ::--:: Define Menu ::--::

        self.fileMenu()
        self.viewMenu()
        self.helpMenu()

    ## ::--:: End Define Menu ::--::

## ::----:: Menu Code ::----::

    def fileMenu(self):
        
        self.mb = Menubutton(self, text="File", relief=RIDGE, font=("Arial", 10))
        self.mb.grid(row=0, column=0)
        self.mb.menu = Menu(self.mb, tearoff=1)
        self.mb["menu"] = self.mb.menu
        self.optionVar = IntVar()
        self.closeVar = IntVar()
        self.mb.menu.add_checkbutton(label="Options", variable=self.optionVar)
        self.mb.menu.add_command(label="Close", command=self.quit)

    def viewMenu(self):
        
        self.mb = Menubutton(self, text="View", relief=RIDGE, font=("Arial", 10))
        self.mb.grid(row=0, column=2)
        self.mb.menu = Menu(self.mb, tearoff=1)
        self.mb["menu"] = self.mb.menu
        self.presetColourVar = IntVar()
        self.gridlinesVar = IntVar()
        self.size_normVar = IntVar()
        self.size_oneVar = IntVar()
        self.size_twoVar = IntVar()
        self.size_threeVar = IntVar()
        self.mb.menu.add_checkbutton(label="Colours", variable=self.presetColourVar)
        self.mb.menu.add_checkbutton(label="Grid Lines", variable=self.gridlinesVar)
        self.mb.menu.add_checkbutton(label="Size Norm ", variable=self.size_normVar)
        self.mb.menu.add_checkbutton(label="Size 1 ", variable=self.size_oneVar)
        self.mb.menu.add_checkbutton(label="Size 2 ", variable=self.size_twoVar)
        self.mb.menu.add_checkbutton(label="Size 3 ", variable=self.size_threeVar)

    def helpMenu(self):

        self.mb = Menubutton(self, text="Help", relief=RIDGE, font=("Arial", 10))
        self.mb.grid(row=0, column=1)
        self.mb.menu = Menu(self.mb, tearoff=1)
        self.mb["menu"] = self.mb.menu
        self.helpFileVar = IntVar()
        self.helpWikiVar = IntVar()
        self.creditVar = IntVar()
        self.mb.menu.add_checkbutton(label="Help File", variable=self.helpFileVar)
        self.mb.menu.add_checkbutton(label="Help Wiki", variable=self.helpWikiVar)
        self.mb.menu.add_checkbutton(label="Credits", variable=self.helpWikiVar)

## ::----:: End Menu Code ::----::

## ::----:: Parent Tk Window ::----::

class Program_Window():

    def __init__(self):
        
        self.root = Tk()
        self.root.title('Major Project - SDD. secondGen_v0.01')
        self.root.geometry('1000x600+140+90')
        
    def menu_Control(self):
        controlMenu()

    # def (self):
    # def (self):
    # def (self):

        
## ::----:: End Parent Tk Window ::----::
## ::----:: Run Program ::----::
        


mw = Program_Window()
mw.menu_Control()

## ::----:: End Run Program ::----::
## ::----:: End GUI Window Code::----::