Mein Testprogramm sieht jetzt so aus:
Code
import wNim
const sTitle = "My Gui-Window"
let app = App()
let frame = Frame(title=sTitle, size=(640, 480))
frame.icon = Icon(r"prog.ico")
frame.dpiAutoScale:
frame.minSize = (480, 320)
frame.maxSize = (1024, 768)
let menuBar = MenuBar(frame)
let statusBar = StatusBar(frame)
let menu = Menu(menuBar, "&File")
menu.append(wIdExit, "E&xit\tAlt-F4", "Close window and exit program.")
let accel = AcceleratorTable(frame)
accel.add(wAccelAlt, wKey_F4, wIdExit)
let panel = Panel(frame)
const myJpg = staticRead(r"test.jpg")
let myImage = Image(myJpg).scale(640, 480)
let staticbitmap = StaticBitmap(panel, bitmap=Bitmap(myImage))
let staticText = StaticText(panel, label="Hello, World!")
staticText.font = Font(14, family=wFontFamilySwiss, weight=wFontWeightBold)
staticText.cursor = wHandCursor
staticText.fit()
let button = Button(panel, label="Font", pos=(0, 80))
let button2 = Button(panel, label="Test", pos=(0, 10))
proc layout() =
panel.autolayout """
HV:|-[staticbitmap]-|
H:|-[staticText]->[button]-|
H:|-[staticText]->[button2]-|
"""
staticText.wEvent_CommandLeftClick do ():
let textEntryDialog = TextEntryDialog(frame, value=staticText.label,
caption="Change The Text")
if textEntryDialog.showModal() == wIdOk:
staticText.label = textEntryDialog.value
staticText.fit()
staticText.refresh()
button.wEvent_Button do ():
let fontDialog = FontDialog(frame, staticText.font)
fontDialog.color = staticText.foregroundColor
fontDialog.enableSymbols(false)
fontDialog.range = 0..72
if fontDialog.showModal() == wIdOk:
staticText.font = fontDialog.chosenFont
staticText.foregroundColor = fontDialog.color
staticText.fit()
staticText.refresh()
frame.wIdExit do ():
frame.close()
frame.wEvent_Close do (event: wEvent):
statusBar.setStatusText("Das Programm wirklich beenden?")
let dlg = MessageDialog(frame, "Das Programm wirklich beenden?",
sTitle, wYesNo or wIconQuestion)
if dlg.showModal() != wIdYes:
event.veto()
panel.wEvent_Size do ():
layout()
layout()
frame.center()
frame.show()
app.mainLoop()
Alles anzeigen
Wie kann ich den Style der Gui-Elemente beeinflussen?
Ich hätte gern, dass die Schrift transparent auf dem Hintergrundbild ist.
Und das Hintergrundbild verhindert das betätigen der Buttons. Also muss wohl irgendwie der Klick auf das Bild deaktiviert werden (wie in AutoIt). Aber wie?