2016 Update
This commit is contained in:
parent
948b86eafa
commit
dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions
|
|
@ -1,2 +1,8 @@
|
|||
This task asks to create a window with a label that says "There have been no clicks yet" and a button that says "click me".
|
||||
;Task:
|
||||
Create a window that has:
|
||||
::# a label that says "There have been no clicks yet"
|
||||
::# a button that says "click me"
|
||||
|
||||
|
||||
Upon clicking the button with the mouse, the label should change and show the number of times the button has been clicked.
|
||||
<br><br>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,24 @@
|
|||
#include <ButtonConstants.au3>
|
||||
#include <GUIConstantsEx.au3>
|
||||
#include <StaticConstants.au3>
|
||||
#include <WindowsConstants.au3>
|
||||
#Region ### START Koda GUI section ###
|
||||
Local $GUI = GUICreate("Clicks", 280, 50, (@DesktopWidth - 280) / 2, (@DesktopHeight - 50) / 2)
|
||||
Local $lblClicks = GUICtrlCreateLabel("There have been no clicks yet", 0, 0, 278, 20, $SS_CENTER)
|
||||
Local $btnClicks = GUICtrlCreateButton("CLICK ME", 104, 25, 75, 25)
|
||||
GUISetState(@SW_SHOW)
|
||||
#EndRegion ### END Koda GUI section ###
|
||||
|
||||
Local $counter = 0
|
||||
|
||||
While 1
|
||||
$nMsg = GUIGetMsg()
|
||||
Switch $nMsg
|
||||
Case $GUI_EVENT_CLOSE
|
||||
Exit
|
||||
|
||||
Case $btnClicks
|
||||
$counter += 1
|
||||
GUICtrlSetData($lblClicks, "Times clicked: " & $counter)
|
||||
EndSwitch
|
||||
WEnd
|
||||
|
|
@ -1,33 +1,33 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/mattn/go-gtk/gtk"
|
||||
"fmt"
|
||||
"github.com/mattn/go-gtk/gtk"
|
||||
)
|
||||
|
||||
func main() {
|
||||
gtk.Init(nil)
|
||||
window := gtk.Window(gtk.GTK_WINDOW_TOPLEVEL)
|
||||
window.SetTitle("Click me")
|
||||
label := gtk.Label("There have been no clicks yet")
|
||||
var clicks int
|
||||
button := gtk.ButtonWithLabel("click me")
|
||||
button.Clicked(func() {
|
||||
clicks++
|
||||
if clicks == 1 {
|
||||
label.SetLabel("Button clicked 1 time")
|
||||
} else {
|
||||
label.SetLabel(fmt.Sprintf("Button clicked %d times",
|
||||
clicks))
|
||||
}
|
||||
})
|
||||
vbox := gtk.VBox(false, 1)
|
||||
vbox.Add(label)
|
||||
vbox.Add(button)
|
||||
window.Add(vbox)
|
||||
window.Connect("destroy", func() {
|
||||
gtk.MainQuit()
|
||||
})
|
||||
window.ShowAll()
|
||||
gtk.Main()
|
||||
gtk.Init(nil)
|
||||
window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
|
||||
window.SetTitle("Click me")
|
||||
label := gtk.NewLabel("There have been no clicks yet")
|
||||
var clicks int
|
||||
button := gtk.NewButtonWithLabel("click me")
|
||||
button.Clicked(func() {
|
||||
clicks++
|
||||
if clicks == 1 {
|
||||
label.SetLabel("Button clicked 1 time")
|
||||
} else {
|
||||
label.SetLabel(fmt.Sprintf("Button clicked %d times",
|
||||
clicks))
|
||||
}
|
||||
})
|
||||
vbox := gtk.NewVBox(false, 1)
|
||||
vbox.Add(label)
|
||||
vbox.Add(button)
|
||||
window.Add(vbox)
|
||||
window.Connect("destroy", func() {
|
||||
gtk.MainQuit()
|
||||
})
|
||||
window.ShowAll()
|
||||
gtk.Main()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,20 @@
|
|||
$Label1 = [System.Windows.Forms.Label]@{
|
||||
Text = 'There have been no clicks yet'
|
||||
Size = '200, 20' }
|
||||
$Button1 = [System.Windows.Forms.Button]@{
|
||||
Text = 'Click me'
|
||||
Location = '0, 20' }
|
||||
|
||||
$Button1.Add_Click(
|
||||
{
|
||||
$Script:Clicks++
|
||||
If ( $Clicks -eq 1 ) { $Label1.Text = "There has been 1 click" }
|
||||
Else { $Label1.Text = "There have been $Clicks clicks" }
|
||||
} )
|
||||
|
||||
$Form1 = New-Object System.Windows.Forms.Form
|
||||
$Form1.Controls.AddRange( @( $Label1, $Button1 ) )
|
||||
|
||||
$Clicks = 0
|
||||
|
||||
$Result = $Form1.ShowDialog()
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
Add-Type -AssemblyName System.Windows.Forms
|
||||
|
||||
$Label1 = New-Object System.Windows.Forms.Label
|
||||
$Label1.Text = 'There have been no clicks yet'
|
||||
$Label1.Size = '200, 20'
|
||||
|
||||
$Button1 = New-Object System.Windows.Forms.Button
|
||||
$Button1.Text = 'Click me'
|
||||
$Button1.Location = '0, 20'
|
||||
|
||||
$Button1.Add_Click(
|
||||
{
|
||||
$Script:Clicks++
|
||||
If ( $Clicks -eq 1 ) { $Label1.Text = "There has been 1 click" }
|
||||
Else { $Label1.Text = "There have been $Clicks clicks" }
|
||||
} )
|
||||
|
||||
$Form1 = New-Object System.Windows.Forms.Form
|
||||
$Form1.Controls.AddRange( @( $Label1, $Button1 ) )
|
||||
|
||||
$Clicks = 0
|
||||
|
||||
$Result = $Form1.ShowDialog()
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
[xml]$Xaml = @"
|
||||
<Window
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
x:Name = "Window1"
|
||||
Width = "200"
|
||||
Height = "120"
|
||||
ShowInTaskbar = "True">
|
||||
<StackPanel>
|
||||
<Label
|
||||
x:Name = "Label1"
|
||||
Height = "40"
|
||||
Width = "200"
|
||||
Content = "There have been no clicks"/>
|
||||
<Button
|
||||
x:Name = "Button1"
|
||||
Height = "25"
|
||||
Width = "60"
|
||||
Content = "Click me"/>
|
||||
</StackPanel>
|
||||
</Window>
|
||||
"@
|
||||
|
||||
$Window1 = [Windows.Markup.XamlReader]::Load( [System.Xml.XmlNodeReader]$Xaml )
|
||||
|
||||
$Label1 = $Window1.FindName( "Label1" )
|
||||
$Button1 = $Window1.FindName( "Button1" )
|
||||
|
||||
$Button1.Add_Click(
|
||||
{
|
||||
$Script:Clicks++
|
||||
If ( $Clicks -eq 1 ) { $Label1.Content = "There has been 1 click" }
|
||||
Else { $Label1.Content = "There have been $Clicks clicks" }
|
||||
} )
|
||||
|
||||
$Clicks = 0
|
||||
|
||||
$Result = $Window1.ShowDialog()
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
$count = 0
|
||||
|
||||
New-Window {
|
||||
New-StackPanel {
|
||||
New-TextBlock "There have been no clicks yet" `
|
||||
-On_Loaded {
|
||||
Set-Variable tb $this
|
||||
}
|
||||
New-Button "Click me" `
|
||||
-On_Click {
|
||||
$count++
|
||||
$tb.Text = $count
|
||||
}
|
||||
}
|
||||
} -SizeToContent WidthAndHeight -Show
|
||||
|
|
@ -1,32 +1,27 @@
|
|||
Global Window_0
|
||||
Global Window_0_Text_0
|
||||
Global Window_0_Button_1
|
||||
Global Clicks, txt$
|
||||
Define window_0
|
||||
Define window_0_Text_0, window_0_Button_1
|
||||
Define clicks, txt$, flags
|
||||
|
||||
Procedure OpenWindow_Window_0()
|
||||
Protected flags=#PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_TitleBar|#PB_Window_WindowCentered
|
||||
Window_0 = OpenWindow(#PB_Any, 408, 104, 280, 45, "Simple windowed application", flags)
|
||||
If Window_0
|
||||
SmartWindowRefresh(Window_0, #True)
|
||||
Window_0_Text_0 = TextGadget(#PB_Any, 5, 5, 165, 20, "There have been no clicks yet")
|
||||
Window_0_Button_1 = ButtonGadget(#PB_Any, 190, 10, 85, 30, "Click me")
|
||||
EndIf
|
||||
EndProcedure
|
||||
flags = #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_ScreenCentered
|
||||
window_0 = OpenWindow(#PB_Any, 408, 104, 280, 45, "Simple windowed application", flags)
|
||||
If window_0
|
||||
SmartWindowRefresh(window_0, #True)
|
||||
window_0_Text_0 = TextGadget(#PB_Any, 5, 5, 165, 20, "There have been no clicks yet")
|
||||
window_0_Button_1 = ButtonGadget(#PB_Any, 190, 10, 85, 30, "Click me")
|
||||
|
||||
OpenWindow_Window_0()
|
||||
|
||||
Repeat
|
||||
Select WaitWindowEvent()
|
||||
Case #PB_Event_Gadget
|
||||
Select EventGadget()
|
||||
Case Window_0_Text_0
|
||||
Case Window_0_Button_1
|
||||
Clicks+1
|
||||
txt$="You Clicked "+Str(Clicks)+" time"
|
||||
If Clicks>1: txt$+"s": EndIf
|
||||
SetGadgetText(Window_0_Text_0,txt$)
|
||||
EndSelect
|
||||
Case #PB_Event_CloseWindow
|
||||
End
|
||||
EndSelect
|
||||
ForEver
|
||||
Repeat
|
||||
Select WaitWindowEvent()
|
||||
Case #PB_Event_Gadget
|
||||
Select EventGadget()
|
||||
Case window_0_Text_0
|
||||
Case window_0_Button_1
|
||||
clicks + 1
|
||||
txt$ = "You Clicked " + Str(clicks) + " time"
|
||||
If clicks > 1: txt$ + "s": EndIf
|
||||
SetGadgetText(window_0_Text_0, txt$)
|
||||
EndSelect
|
||||
Case #PB_Event_CloseWindow
|
||||
End
|
||||
EndSelect
|
||||
ForEver
|
||||
EndIf
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue