Hello all. I am trying to create a gui for an email application. It should be able to speak to pop3. I have a very basic interface in development. My question is, i have 3 buttons From, Date and Subject. I want to be able to sort by these buttons (sort of like how outlook is set up). Here's the code I have for what i have now. Also if you have any tips on connecting to pop3 w/o using the pop library would be appreciated. Thanks.
catch {console show}
set auto_path [linsert $auto_path 0 [file dirname [info script]]]
proc OpenProc {} {
WriteInfoStr "You selected OpenProc"
}
proc CloseProc {} {
WriteInfoStr "You selected CloseProc"
}
proc HelpProc {} {
WriteInfoStr "You selected HelpProc"
}
proc AddMenuCmd { menu label acc cmd } {
$menu add command -label $label -accelerator $acc -command $cmd
}
proc WriteInfoStr { str } {
.fr.infofr.l configure -text $str
}
set hMenu .menufr
menu $hMenu -borderwidth 2 -relief sunken
$hMenu add cascade -menu $hMenu.file -label File -underline 0
$hMenu add cascade -menu $hMenu.help -label Help -underline 0
set fileMenu $hMenu.file
menu $fileMenu -tearoff 0
AddMenuCmd $fileMenu "Open ..." "Ctrl+O" OpenProc
AddMenuCmd $fileMenu "Close ..." "Ctrl+W" CloseProc
AddMenuCmd $fileMenu "Quit ..." "Ctrl+Q" exit
bind . <Control-o> OpenProc
bind . <Control-w> CloseProc
bind . <Control-q> exit
set helpMenu $hMenu.help
menu $helpMenu -tearoff 0
AddMenuCmd $helpMenu "About ..." "F1" HelpProc
bind . <F1> HelpProc
wm protocol . WM_DELETE_WINDOW "exit"
. configure -menu $hMenu
frame .fr
pack .fr -fill both -expand 1
frame .fr.toolfr -relief sunken -borderwidth 1
frame .fr.listfr -relief sunken -borderwidth 1 -bg white
frame .fr.infofr -relief sunken -borderwidth 1 -bg cyan
frame .fr.workfr -relief sunken -borderwidth 1 -bg green
# Create toolbar buttons
image create photo .open -format GIF -file open.gif
button .fr.toolfr.open -image .open -width 100 -height 30
image create photo .delete -format GIF -file delete_button.gif
button .fr.toolfr.delete -image .delete -width 100 -height 30
image create photo .exit -format GIF -file exit.gif
button .fr.toolfr.exit -image .exit -width 100 -height 30 -command exit
pack .fr.toolfr.open .fr.toolfr.delete .fr.toolfr.exit -side left -padx 2 -pady 2 -expand 0
pack .fr.toolfr -side top -fill x
# Toolbar is on the top row of grid
grid .fr.toolfr -row 0 -column 0 -sticky ew
# List of mail is on the second row of grid
# Need to create three columns for list of From, Date, Subject
button .fr.listfr.from -text From -command sort_From
button .fr.listfr.date -text Date -command sort_Date
button .fr.listfr.subject -text Subject -command sort_Subject
pack .fr.listfr.from .fr.listfr.date .fr.listfr.subject -side left -fill x
pack .fr -side top
grid .fr.listfr -row 1 -column 0 -ipadx 200 -ipady 50 -sticky ew
# Info on the open mail message is on the third row of grid
grid .fr.infofr -row 2 -column 0 -ipadx 200 -ipady 20 -sticky ew
# Messaage is on the fourth row of grid
grid .fr.workfr -row 3 -column 0 -ipadx 200 -ipady 70 -sticky ew
grid rowconfigure .fr 1 -weight 1
grid columnconfigure .fr 0 -weight 1
label .fr.listfr.l \
-text "List of mail goes here; with From, Date, Subject columns" \
-bg white
pack .fr.listfr.l \
-fill x -expand 1
label .fr.infofr.l \
-text "Mail Info goes here; display From:, Date:, Subject: of the open message" \
-bg cyan
pack .fr.infofr.l \
-fill x -expand 1
label .fr.workfr.l \
-text "Message body goes here" \
-bg green
pack .fr.workfr.l \
-fill x -expand 1
catch {console show}
set auto_path [linsert $auto_path 0 [file dirname [info script]]]
proc OpenProc {} {
WriteInfoStr "You selected OpenProc"
}
proc CloseProc {} {
WriteInfoStr "You selected CloseProc"
}
proc HelpProc {} {
WriteInfoStr "You selected HelpProc"
}
proc AddMenuCmd { menu label acc cmd } {
$menu add command -label $label -accelerator $acc -command $cmd
}
proc WriteInfoStr { str } {
.fr.infofr.l configure -text $str
}
set hMenu .menufr
menu $hMenu -borderwidth 2 -relief sunken
$hMenu add cascade -menu $hMenu.file -label File -underline 0
$hMenu add cascade -menu $hMenu.help -label Help -underline 0
set fileMenu $hMenu.file
menu $fileMenu -tearoff 0
AddMenuCmd $fileMenu "Open ..." "Ctrl+O" OpenProc
AddMenuCmd $fileMenu "Close ..." "Ctrl+W" CloseProc
AddMenuCmd $fileMenu "Quit ..." "Ctrl+Q" exit
bind . <Control-o> OpenProc
bind . <Control-w> CloseProc
bind . <Control-q> exit
set helpMenu $hMenu.help
menu $helpMenu -tearoff 0
AddMenuCmd $helpMenu "About ..." "F1" HelpProc
bind . <F1> HelpProc
wm protocol . WM_DELETE_WINDOW "exit"
. configure -menu $hMenu
frame .fr
pack .fr -fill both -expand 1
frame .fr.toolfr -relief sunken -borderwidth 1
frame .fr.listfr -relief sunken -borderwidth 1 -bg white
frame .fr.infofr -relief sunken -borderwidth 1 -bg cyan
frame .fr.workfr -relief sunken -borderwidth 1 -bg green
# Create toolbar buttons
image create photo .open -format GIF -file open.gif
button .fr.toolfr.open -image .open -width 100 -height 30
image create photo .delete -format GIF -file delete_button.gif
button .fr.toolfr.delete -image .delete -width 100 -height 30
image create photo .exit -format GIF -file exit.gif
button .fr.toolfr.exit -image .exit -width 100 -height 30 -command exit
pack .fr.toolfr.open .fr.toolfr.delete .fr.toolfr.exit -side left -padx 2 -pady 2 -expand 0
pack .fr.toolfr -side top -fill x
# Toolbar is on the top row of grid
grid .fr.toolfr -row 0 -column 0 -sticky ew
# List of mail is on the second row of grid
# Need to create three columns for list of From, Date, Subject
button .fr.listfr.from -text From -command sort_From
button .fr.listfr.date -text Date -command sort_Date
button .fr.listfr.subject -text Subject -command sort_Subject
pack .fr.listfr.from .fr.listfr.date .fr.listfr.subject -side left -fill x
pack .fr -side top
grid .fr.listfr -row 1 -column 0 -ipadx 200 -ipady 50 -sticky ew
# Info on the open mail message is on the third row of grid
grid .fr.infofr -row 2 -column 0 -ipadx 200 -ipady 20 -sticky ew
# Messaage is on the fourth row of grid
grid .fr.workfr -row 3 -column 0 -ipadx 200 -ipady 70 -sticky ew
grid rowconfigure .fr 1 -weight 1
grid columnconfigure .fr 0 -weight 1
label .fr.listfr.l \
-text "List of mail goes here; with From, Date, Subject columns" \
-bg white
pack .fr.listfr.l \
-fill x -expand 1
label .fr.infofr.l \
-text "Mail Info goes here; display From:, Date:, Subject: of the open message" \
-bg cyan
pack .fr.infofr.l \
-fill x -expand 1
label .fr.workfr.l \
-text "Message body goes here" \
-bg green
pack .fr.workfr.l \
-fill x -expand 1