-
Notifications
You must be signed in to change notification settings - Fork 4
/
winui-click.py
48 lines (37 loc) · 1.45 KB
/
winui-click.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
from win32more.xaml import XamlApplication
from win32more.Windows.Foundation import PropertyValue
from win32more.Microsoft.UI.Xaml import Window
from win32more.Microsoft.UI.Xaml.Controls import StackPanel, TextBlock
from win32more.Microsoft.UI.Xaml.Controls.Primitives import RepeatButton
class App(XamlApplication):
def OnLaunched(self, args):
self.clicks = 0
win = Window()
stack = StackPanel()
incbtn = RepeatButton()
incbtn.Width = 100
incbtn.Delay = 500
incbtn.Interval = 100
incbtn.add_Click(self.Increase_Click)
incbtn.Content = PropertyValue.CreateString("Increase")
decbtn = RepeatButton()
decbtn.Width = 100
decbtn.Delay = 500
decbtn.Interval = 100
decbtn.add_Click(self.Decrease_Click)
decbtn.Content = PropertyValue.CreateString("Decrease")
self.textblock = TextBlock()
self.textblock.Text = "Number of Clicks:"
stack.Children.Append(incbtn)
stack.Children.Append(decbtn)
stack.Children.Append(self.textblock)
win.Content = stack
win.Activate()
def Increase_Click(self, sender, args):
self.clicks += 1
self.textblock.Text = "Number of Clicks: " + str(self.clicks)
def Decrease_Click(self, sender, args):
if(self.clicks > 0):
self.clicks -= 1
self.textblock.Text = "Number of Clicks: " + str(self.clicks)
XamlApplication.Start(App)