FREEWEBLAYOUTSET - 101--

 FREEWEBLAYOUTSET - 101--
WATCH US LOOK GOOD put OK/Cancel buttons on the dialog - parts of this lifted from TkSimpleDialog
ButtonFrame = Frame(self)
OKButton = Button( ButtonFrame, text="OK", width=10,
command=self.OnOK, default=ACTIVE )
OKButton.pack(side=LEFT, padx=5, pady=5)
CancelButton = Button( ButtonFrame, text="Cancel", width=10,
command=self.OnCancel )
CancelButton.pack(side=LEFT, padx=5, pady=5)
ButtonFrame.pack()

self.bind("<Return>", self.OnOK)
self.bind("<Escape>", self.OnCancel)


def OnOK(self, event=None):
''' called by pressing the OK button - validates data, and if no error
sets a good return code and dismisses the dialog by calling OnCancel
[ Ajouter un commentaire ] [ Aucun commentaire ]

# Posté le vendredi 10 août 2007 21:31

Modifié le samedi 14 février 2009 06:52

FREEWEBLAYOUTSET - 104 -

FREEWEBLAYOUTSET - 104 -
try:
X = self.GridLinesX.get()

except ValueError:
X = 0

try:
Y = self.GridLinesY.get()
except ValueError:
Y = 0

try:
Pad = self.PadAmount.get()
except ValueError:
Pad = -1

if X < 1 or X > self.ImageCount:
tkMessageBox.showerror( 'Cells across invalid',
'Cells across must be less than %d' % self.ImageCount )
return
if Y < 1 or Y > self.ImageCount:
tkMessageBox.showerror( 'Cells down invalid',
'Cells down must be less than %d' % self.ImageCount )
return
if X * Y < self.ImageCount:
tkMessageBox.showerror( 'Not enough cells',
'Cells across x cells down must be at least %d' % self.ImageCount )
return
[ Ajouter un commentaire ] [ Aucun commentaire ]

# Posté le vendredi 10 août 2007 21:24

Modifié le vendredi 28 mars 2008 22:26

FREEWEBLAYOUTSET - 105 -

 FREEWEBLAYOUTSET - 105  -
define all the variables attached to the controls
self.GridLinesX = IntVar()
self.GridLinesX.set( NumCols )

self.GridLinesY = IntVar()
self.GridLinesY.set( NumRows )

self.PadAmount = IntVar()
self.PadAmount.set( 2 )

# define the basics of the window
self.pack(expand=YES, fill=BOTH)
self.master.title('Define Cells')

# put some explanatory text on the window
Label( self, text = 'Enter the cell arrangement of the tube:',
justify=LEFT ).pack(expand=YES, fill=BOTH, side=TOP)

# make a subframe to hold the cells across controls
XFrame = Frame( self )
XLabel = Label( XFrame, text='Cells across:', width=30 )
XLabel.pack( expand=YES, fill=BOTH, side=LEFT )
self.XEntry = Entry( XFrame, textvariable=self.GridLinesX )
self.XEntry.pack( expand=YES, fill=BOTH, side=RIGHT )
XFrame.pack(side=TOP)
[ Ajouter un commentaire ] [ Aucun commentaire ]

# Posté le vendredi 10 août 2007 21:17

Modifié le samedi 21 mars 2009 07:07

FREEWEBLAYOUTSNET - 110 -

FREEWEBLAYOUTSNET - 110 -
OldDifference = Difference

# 2. Seed a dialog with the best fit choices, but let the user override. The number
# of cells they create must be sufficient for the number of images that will be
# tubed.
# create the root TK window
root = Tk()

# create the dialog and show the dialog
Dlg = CellCountDlg( root, 'Cell Layout', NumCols, NumRows, len(IncludedDocs) )

# tell PSP that a foreign dialog is running. This causes PSP to do some additional
# work to keep the UI updating properly and to prevent the script window from going
# behind PSP.
App.Do( Environment, 'StartForeignWindow', { 'WindowHandle': int(Dlg.winfo_id()) } )

root.mainloop()
root.destroy()
App.Do( Environment, 'StartForeignWindow', { 'WindowHandle': 0 } )
[ Ajouter
[ Ajouter un commentaire ] [ Aucun commentaire ]

# Posté le vendredi 10 août 2007 15:22

Modifié le vendredi 04 avril 2008 22:08

FREEWEBLAYOUTSET - 111 -

 FREEWEBLAYOUTSET - 111 -
walk down OldDifference = Difference

# 2. Seed a dialog with the best fit choices, but let the user override. The number
# of cells they create must be sufficient for the number of images that will be
# tubed.
# create the root TK window
root = Tk()

# create the dialog and show the dialog
Dlg = CellCountDlg( root, 'Cell Layout', NumCols, NumRows, len(IncludedDocs) )

# tell PSP that a foreign dialog is running. This causes PSP to do some additional
# work to keep the UI updating properly and to prevent the script window from going
# behind PSP.
App.Do( Environment, 'StartForeignWindow', { 'WindowHandle': int(Dlg.winfo_id()) } )

root.mainloop()
root.destroy()
App.Do( Environment, 'StartForeignWindow', { 'WindowHandle': 0 } )
[ Ajouter
[ Ajouter un commentaire ] [ Aucun commentaire ]

# Posté le vendredi 10 août 2007 15:16

Modifié le samedi 21 mars 2009 07:06