Hello,
I am very new to Newlisp.
I am trying to learn Newlisp and was trying to make a calculator program.
I was wondering how to I could get tk to diplay all the buttons on one line instead of putting the buttons on a new line? Here is my code:
(define (calc)
(tk "toplevel .mywin")
(tk "button .mywin.add -relief flat -overrelief raised -text ADD")
(tk "pack .mywin.add -padx 30 -pady 20")
(tk "button .mywin.subtract -relief flat -overrelief raised -text SUBTRACT")
(tk "pack .mywin.subtract -padx 30 -pady 20")
(tk "button .mywin.multiply -relief flat -overrelief raised -text MULTIPLY")
(tk "pack .mywin.multiply -padx 30 -pady 20")
(tk "button .mywin.divide -relief flat -overrelief raised -text DIVIDE")
(tk "pack .mywin.divide -padx 10 -pady 10")
)
I hope you can understand my question. Thanks for any help.
How do you get it to put buttons on one line
How do you get it to put buttons on one line
I am a newbe so please help me
Hello ericsm,
you need some additional knowledge about TK since this is not a newLISP problem. Or buy a book about TK.
You can use frames in TK to line up buttons.
See ..\newlisp-8.8.4\newlisp-tk\newlisp-tk.tcl from the source distribution and have a look at procedure 'SetupConsoleToolbar'.
And in SetupConsole you see how it is aranged in toplevel window.
you need some additional knowledge about TK since this is not a newLISP problem. Or buy a book about TK.
You can use frames in TK to line up buttons.
See ..\newlisp-8.8.4\newlisp-tk\newlisp-tk.tcl from the source distribution and have a look at procedure 'SetupConsoleToolbar'.
Code: Select all
proc SetupConsoleToolbar { widget } {
global Ide
frame .bframe
foreach name {openImg saveImg reloadImg editImg debugImg copyImg cutImg pasteImg clearImg
helpImg nltkImg } {
[set $name [image create photo]] read "$Ide(imageDir)/$name.gif"
}
foreach no {1 2 3 4 5} {
label .bframe.vertical$no -text { } -relief flat
}
set st groove
button .bframe.open -image $openImg -relief $st -command LoadFile
button .bframe.reload -image $reloadImg -relief $st -command ReLoadFile
button .bframe.save -image $saveImg -relief $st -command SaveAllFile
button .bframe.edit -image $editImg -relief $st -command CodeBrowser
button .bframe.debug -image $debugImg -relief $st -command Debugger
button .bframe.copy -image $copyImg -relief $st -command "event generate $widget <Control-c>"
button .bframe.cut -image $cutImg -relief $st -command "event generate $widget <Control-x>"
button .bframe.paste -image $pasteImg -relief $st -command "event generate $widget <Control-v>"
button .bframe.clear -image $clearImg -relief $st -command "ClearConsoleScreen"
button .bframe.help -image $helpImg -relief $st -command HelpAction
button .bframe.nltk -image $nltkImg -relief $st -command HelpAction-tk
pack .bframe.open .bframe.reload .bframe.save .bframe.vertical1 -side left
pack .bframe.edit .bframe.debug .bframe.vertical2 -side left
pack .bframe.copy .bframe.cut .bframe.paste .bframe.vertical3 -side left
pack .bframe.clear .bframe.vertical5 -side left -padx 1
pack .bframe.help .bframe.nltk -side left
balloon_help .bframe.open { Load source Ctrl-O }
balloon_help .bframe.reload { Reload last source Ctrl-R }
balloon_help .bframe.save { Save workspace Ctrl-S }
balloon_help .bframe.edit { Browser / Editor Ctrl-B }
balloon_help .bframe.debug { Debugger Ctrl-G }
balloon_help .bframe.copy { Copy selection Ctrl-C }
balloon_help .bframe.cut { Cut selection Ctrl-X }
balloon_help .bframe.paste { Paste selection Ctrl-V }
balloon_help .bframe.clear { Clear console Ctrl-L }
balloon_help .bframe.help { newLISP Reference Ctrl-M }
balloon_help .bframe.nltk { newLISP-tk Intro Ctrl-K }
return .bframe
}
Hans-Peter