[BangPypers] Python GUI Tkinter Button arrangement

Bugcy 013 bugcy013 at gmail.com
Tue Feb 15 16:29:56 CET 2011


Hi..

I am new to python , i have creating one application user agreement..using
Tkinter, The Content

of the agreement will reading one file...Agree button will click means
enable next button. And activate script,

Quit button for exit the program,, Dis agree means one warning message will
show up..

all are working but one buttons are top of the screen.  *i want button in
bottom of the frame plz*. help me..

this my source code



#!/usr/bin/python

from Tkinter import Tk, RIGHT, BOTH, RAISED
from ttk import Frame, Button, Style
import sys
import os
sys.path[:0] = ['../../..']
import string
import Tkinter
import Pmw
import wx
from Tkinter import *
import tkMessageBox
import gtk
b1 = 'True'
c1 = 'False'
a1 = 1



class Example(Frame):

    def __init__(self1, parent):
        Frame.__init__(self1, parent)

        self1.parent = parent

        self1.initUI()

        #fixedFont = Pmw.logicalfont('Fixed')
       self1.st = Pmw.ScrolledText(parent,
 labelpos = 'n',
label_text='User Aggrement',


usehullsize = 1,
hull_width = 600,
hull_height = 400,
 text_wrap='none',
#text_font = fixedFont,

text_padx = 4,
 text_pady = 4,
)
self1.st.importfile('python.txt');
 self1.st.pack(padx = 5, pady = 5, fill = 'both', expand = 1)

        # Prevent users' modifying text and headers
 self1.st.configure(text_state = 'disabled')

    def initUI(self1):

        self1.parent.title("User Aggrement")
        self1.style = Style()
        self1.style.theme_use("default")

        frame = Frame(self1, relief=RAISED, borderwidth=.5)
        frame.pack(fill=BOTH, expand=1)

        self1.pack(fill=BOTH, expand=1)

def buttonPress(var):
#print 'The "%s" button was pressed' % var
 if var == 'ok':
#os.system("ls -l") & os.system("man man")
 widget.configure(state=NORMAL)
elif var == 'dhana':
os.system("top &") & exit()
 elif var == 'close':
  a1 = tkMessageBox.askyesno("DisAgree", "Do you really wish to Disagree?" )
#print a1
 if a1 == 1:
exit()
 else:
sys.exit

        widget = Tkinter.Button(self1, text='Next',command = lambda
b='dhana':     buttonPress(b) )
        widget.pack(side=RIGHT, padx=5, pady=5)
        widget.configure(state=DISABLED )


def defaultKey(event):
 def make_widgets(self1):
buttonBox.invoke()
self1.make_widgets()
 root = Tkinter.tk()
         okButton = Tkinter.Button(self1, text="Quit",command = sys.exit  ,
font=('Arial', 10), fg="black")
        okButton.pack(side=RIGHT, padx=5, pady=5)


        CloseButton = Tkinter.Button(self1, text="DisAgree",command = lambda
b='close':     buttonPress(b) , font=('Arial', 10), fg="black")
        CloseButton.pack(side=RIGHT, padx=5, pady=5)

        okButton = Tkinter.Button(self1, text="Agree",command = lambda
b='ok':     buttonPress(b) , font=('Arial', 10), fg="black")
        okButton.pack(side=RIGHT, padx=5, pady=5)
        okButton.focus_force()
        #self1.mainloop()

 ########################################################################################################################################


def main():

    root = Tkinter.Tk()
    root.geometry("600x400+30+30")
    app = Example(root)
    root.mainloop()


if __name__ == '__main__':
    main()






-- 
Did I learn something today? If not, I wasted it.


More information about the BangPypers mailing list