Skip to content

Commit b01d2de

Browse files
committed
First beta release
1 parent dfd93d1 commit b01d2de

41 files changed

Lines changed: 595 additions & 1908 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

helper/WinDialog/__init__.py

Lines changed: 107 additions & 105 deletions
Large diffs are not rendered by default.
Lines changed: 14 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,32 @@
11
from Npp import console
22
from WinDialog import (
33
Dialog, create_dialog_from_rc,
4-
Button, UpDown
4+
Button
55
)
6+
from WinDialog.controls.button import BST
67

78
console.show()
89

910
rc = '''
1011
1 DIALOGEX 0, 0, 250, 100
1112
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
12-
CAPTION "StatusBar Dialog"
13+
CAPTION "Test Dialog"
1314
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
1415
FONT 9, "Segoe UI"
1516
{
16-
CONTROL "", 0, "msctls_updown32", WS_CHILD | WS_VISIBLE | WS_TABSTOP, 19, 18, 10, 20
17-
CONTROL "Get value", 0, BUTTON, BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 31, 18, 69, 20
18-
CONTROL "Set Range", 1, BUTTON, BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 102, 18, 69, 20
17+
CONTROL "btn_3", 2, BUTTON, BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 31, 18, 30, 20
18+
CONTROL "btn_0", 4, BUTTON, BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 91, 18, 30, 20
19+
CONTROL "btn_4", 0, BUTTON, BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 61, 18, 30, 20
20+
CONTROL "btn_1", 1, BUTTON, BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 121, 18, 30, 20
21+
CONTROL "btn_2", 3, BUTTON, BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 151, 18, 30, 20
1922
}
2023
'''
21-
22-
def get_value():
23-
print(dlg.msctls_updown32_0.get_value())
24-
25-
def set_range():
26-
print(dlg.msctls_updown32_0.set_range(-5, 5))
27-
24+
def on_init():
25+
dlg.button_1.setCheckState(BST.CHECKED)
26+
print(dlg.button_0.getCheckState())
27+
print(dlg.button_1.getCheckState())
2828

2929
dlg = create_dialog_from_rc(rc_code=rc)
30-
dlg.msctls_updown32_0.set_range(0, 5)
31-
dlg.button_0.on_click = get_value
32-
dlg.button_1.on_click = set_range
30+
dlg.initialize = on_init
3331
dlg.center = True
34-
dlg.show()
35-
36-
class UpDownDialog(Dialog):
37-
def __init__(self, title='UpDown Dialog'):
38-
super().__init__(title)
39-
self.size = (250, 100)
40-
self.center = True
41-
self.btn0 = Button('Get value', (69, 20), (31, 18))
42-
self.btn1 = Button('Set Range', (69, 20), (102, 18))
43-
self.up_down = UpDown('', (10, 20), (19, 18))
44-
self.btn0.on_click = self.get_value
45-
self.btn1.on_click = self.set_range
46-
self.show()
47-
48-
def get_value(self):
49-
print(self.up_down.get_value())
50-
51-
def set_range(self):
52-
self.up_down.set_range(-5, 5)
53-
54-
UpDownDialog()
55-
56-
# class ScintillaDialog(Dialog):
57-
# def __init__(self, title='Scintilla Dialog'):
58-
# super().__init__(title)
59-
# self.size = (250, 125)
60-
# self.center = True
61-
# self.sci = Scintilla('', (247, 122), (1, 1))
62-
# self.show()
63-
64-
# ScintillaDialog()
32+
dlg.show()

helper/WinDialog/__tests__/stress.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
from Npp import notepad
2-
from WinDialog import Dialog, Button, create_dialog_from_rc
1+
from WinDialog import create_dialog_from_rc
32

43
rc = '''
54
1 DIALOGEX 0, 0, 405, 305
@@ -420,7 +419,7 @@ def on_click():
420419

421420
dlg = create_dialog_from_rc(rc_code=rc)
422421
dlg.title = "MOVE ME AROUND FAST!!! - DELAY IN UPDATING THE POSITION"
423-
dlg.button_0.on_click = on_click
424-
dlg.button_1.on_click = on_cancel
422+
dlg.button_0.onClick = on_click
423+
dlg.button_1.onClick = on_cancel
425424

426425
dlg.show()

helper/WinDialog/__tests__/test_button.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
from Npp import console
2-
from dataclasses import dataclass
1+
32
from WinDialog import (
43
Dialog, create_dialog_from_rc,
54
Button, DefaultButton, CheckBoxButton, GroupBox, CommandButton, RadioButton,
@@ -28,10 +27,10 @@
2827

2928
dlg = create_dialog_from_rc(rc_code=rc)
3029
dlg.center = True
31-
dlg.button_1.on_click = lambda: print('button_1 on_click')
32-
dlg.button_2.on_click = lambda: print('three state button clicked')
33-
dlg.button_9.on_click = dlg.terminate
34-
dlg.button_10.on_click = lambda: print('button_10 on_click')
30+
dlg.button_1.onClick = lambda: print('button_1 on_click')
31+
dlg.button_2.onClick = lambda: print('three state button clicked')
32+
dlg.button_9.onClick = dlg.terminate
33+
dlg.button_10.onClick = lambda: print('button_10 on_click')
3534
dlg.show()
3635

3736
class ButtonDialog(Dialog):
@@ -40,10 +39,10 @@ def __init__(self, title='Some buttons dialog'):
4039
self.size = (250, 200)
4140
self.center = True
4241
self.btn1 = CheckBoxButton(title='Simple', size=(90,14), position=(10, 10))
43-
self.btn1.on_click = lambda: print('btn1 on_click')
42+
self.btn1.onClick = lambda: print('btn1 on_click')
4443
self.btn2 = CheckBoxButton(title='Three state check box', size=(90,14), position=(10, 30))
45-
self.btn2.set_three_state()
46-
self.btn2.on_click = self.three_state_btn_click
44+
self.btn2.setThreeState()
45+
self.btn2.onClick = self.three_state_btn_click
4746

4847
# A new group of radio buttons,
4948
# all following radio buttons are part of this group
@@ -57,10 +56,10 @@ def __init__(self, title='Some buttons dialog'):
5756
self.btn4b = RadioButton('Radio button 2', (60,14), (90, 100))
5857

5958
self.btn5 = DefaultButton(title='Close dialog', size=(80,22), position=(10,130))
60-
self.btn5.on_click = self.terminate
59+
self.btn5.onClick = self.terminate
6160

6261
self.btn6 = Button('Normal push button', (80,22), (90,130))
63-
self.btn6.on_click = lambda: print('btn6 on_click')
62+
self.btn6.onClick = lambda: print('btn6 on_click')
6463

6564
self.btn7 = CommandButton('Command link', (100,26), (10,160))
6665

helper/WinDialog/__tests__/test_combobox.py

Lines changed: 16 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -19,41 +19,25 @@
1919
'''
2020

2121
def on_selchange():
22-
selected_item = dlg.comboboxex32_0.get_selected_item()
22+
selected_item = dlg.comboboxex32_0.getSelectedItem()
2323
if selected_item == 0:
24-
dlg.combobox_0.update(['100', '101', '102',])
24+
dlg.combobox_0.set(['100', '101', '102',])
2525
elif selected_item == 1:
26-
dlg.combobox_0.update(['200', '201', '202',])
26+
dlg.combobox_0.set(['200', '201', '202',])
2727
else:
28-
dlg.combobox_0.update(['300', '301', '302',])
28+
dlg.combobox_0.set(['300', '301', '302',])
2929

3030
def on_selchange2():
31-
print(dlg.comboboxex32_0.items[dlg.comboboxex32_0.get_selected_item()])
31+
print(dlg.combobox_0.getSelectedItem())
3232

3333
def on_init():
34-
dlg.comboboxex32_0.insert_items(['Item1', 'Item2', 'Item3',])
35-
36-
def on_insertitem(args): print('on_insertitem', args._fields_)
37-
def on_deleteitem(args): print('on_deleteitem', args._fields_)
38-
def on_beginedit(args): print('on_beginedit', args._fields_)
39-
def on_endedit(args): print('on_endedit', args._fields_)
40-
def on_getdispinfo(args): print('on_getdispinfo', args._fields_)
41-
def on_dragbegin(args): print('on_dragbegin', args._fields_)
34+
dlg.comboboxex32_0.append(['Item1', 'Item2', 'Item3',])
4235

4336
dlg = create_dialog_from_rc(rc_code=rc)
4437
dlg.center = True
45-
dlg.comboboxex32_0.on_selchange = on_selchange
46-
dlg.comboboxex32_0.on_insertitem = on_insertitem
47-
dlg.comboboxex32_0.on_deleteitem = on_deleteitem
48-
dlg.comboboxex32_0.on_beginedit = on_beginedit
49-
dlg.comboboxex32_0.on_endedit = on_endedit
50-
dlg.comboboxex32_0.on_getdispinfo = on_getdispinfo
51-
dlg.comboboxex32_0.on_dragbegin = on_dragbegin
52-
53-
38+
dlg.comboboxex32_0.onSelChange = on_selchange
5439
dlg.combobox_0.items = []
55-
dlg.combobox_0.on_selchange = on_selchange2
56-
40+
dlg.combobox_0.onSelChange = on_selchange2
5741
dlg.initialize = on_init
5842
dlg.show()
5943

@@ -63,27 +47,27 @@ def __init__(self, title='test dialog'):
6347
self.size = (250, 125)
6448
self.center = True
6549
self.cb1 = ComboBoxEx('', (80,100), (10,10))
66-
self.cb1.on_selchange = self.on_selchange
50+
self.cb1.onSelChange = self.on_selchange
6751

6852
self.cb2 = ComboBox('', (80,100), (10,60))
69-
self.cb2.on_selchange = self.on_selchange2
53+
self.cb2.onSelChange = self.on_selchange2
7054

7155
self.initialize = self.on_init
7256
self.show()
7357

7458
def on_init(self):
75-
self.cb1.insert_items(['Item1', 'Item2', 'Item3',])
59+
self.cb1.append(['Item1', 'Item2', 'Item3',])
7660

7761
def on_selchange(self):
78-
selected_item = self.cb1.get_selected_item()
62+
selected_item = self.cb1.getSelectedItem()
7963
if selected_item == 0:
80-
self.cb2.update(['100', '101', '102',])
64+
self.cb2.set(['100', '101', '102',])
8165
elif selected_item == 1:
82-
self.cb2.update(['200', '201', '202',])
66+
self.cb2.set(['200', '201', '202',])
8367
else:
84-
self.cb2.update(['300', '301', '302',])
68+
self.cb2.set(['300', '301', '302',])
8569

8670
def on_selchange2(self):
87-
print(self.cb1.items[self.cb1.get_selected_item()])
71+
print(self.cb2.getSelectedItem())
8872

8973
ComboBoxDialog()
Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
from Npp import notepad
22
from pathlib import Path
3-
from pprint import pformat
43

5-
from WinDialog import (
6-
Dialog, create_dialog_from_rc,
7-
Button, UpDown
8-
)
4+
from WinDialog import create_dialog_from_rc
95

106
rc = '''
117
1 DIALOGEX 0, 0, 250, 108
@@ -16,7 +12,6 @@
1612
{
1713
CONTROL "", 0, EDIT, ES_LEFT | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 1, 0, 240, 14
1814
CONTROL "", 0, LISTBOX, LBS_STANDARD | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 1, 14, 240, 80
19-
CONTROL "", 0, BUTTON, BS_DEFPUSHBUTTON | WS_CHILD | WS_TABSTOP, 100, 92, 50, 7
2015
}
2116
'''
2217

@@ -25,34 +20,36 @@ def filter_files(files, text):
2520
if file_.startswith(text):
2621
yield file_
2722

28-
2923
config_dir = Path(notepad.getPluginConfigDir())
3024
script_path = config_dir.joinpath("PythonScript\\scripts")
3125
files = dict((x.parts[-1][:-3], x) for x in script_path.iterdir() if x.suffix == '.py')
3226
filtered_list = list(files.keys())
3327
dlg = create_dialog_from_rc(rc_code=rc)
3428

3529
def on_init():
36-
dlg.listbox_0.add_strings(filtered_list)
37-
dlg.edit_0.grab_focus()
30+
dlg.listbox_0.addStrings(filtered_list)
31+
dlg.edit_0.grabFocus()
3832

39-
def on_click():
40-
exec(open(files[filtered_list[0]], 'r').read())
41-
dlg.terminate()
33+
def on_idok():
34+
index = dlg.listbox_0.getSelectedItem()
35+
if index > -1:
36+
print(files[filtered_list[index]])
37+
else:
38+
print(files[filtered_list[0]])
4239

4340
def on_change():
4441
global filtered_list
45-
text = dlg.edit_0.get_text()
42+
text = dlg.edit_0.getText()
4643
dlg.listbox_0.clear()
4744
if text:
4845
filtered_list = list(filter_files(files, text))
49-
dlg.listbox_0.add_strings(filtered_list)
46+
dlg.listbox_0.addStrings(filtered_list)
5047
else:
51-
dlg.listbox_0.add_strings(files)
48+
dlg.listbox_0.addStrings(files)
5249

5350

54-
dlg.edit_0.on_change = on_change
55-
dlg.button_0.on_click = on_click
51+
dlg.edit_0.onChange = on_change
52+
dlg.onIdOk = on_idok
5653
dlg.initialize = on_init
5754
dlg.center = True
5855
dlg.show()

helper/WinDialog/__tests__/test_different_ways_to_create_dialogs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def on_ok():
3838
ok_btn.on_click = on_ok
3939
close_btn = Button(title='&Close', size=(50, 11), position=(187, 78))
4040
close_btn.on_click = on_close
41-
dlg.control_list = [ok_btn, close_btn]
41+
dlg.controlList = [ok_btn, close_btn]
4242
dlg.show()
4343
print(id(dlg))
4444
del(dlg)

helper/WinDialog/__tests__/test_edit.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,16 @@
2222
'''
2323

2424
def get_text():
25-
print(dlg.edit_0.get_text())
25+
print(dlg.edit_0.getText())
2626

2727
def set_text():
28-
dlg.edit_0.set_text('1234567890')
28+
dlg.edit_0.setText('1234567890')
2929

3030
dlg = create_dialog_from_rc(rc_code=rc)
3131
dlg.center = True
3232
dlg.edit_0.on_change = get_text
33-
dlg.button_0.on_click = get_text
34-
dlg.button_1.on_click = set_text
33+
dlg.button_0.onClick = get_text
34+
dlg.button_1.onClick = set_text
3535
dlg.show()
3636

3737

@@ -43,16 +43,16 @@ def __init__(self, title='TextBox Dialog'):
4343
self.textbox = TextBox('123', (240, 12), (5, 5))
4444
self.textbox.on_change = self.get_text
4545
self.button = Button('Get Text', (50, 14), (100, 35))
46-
self.button.on_click = self.get_text
46+
self.button.onClick = self.get_text
4747
self.button2 = Button('Set Text', (50, 14), (100, 55))
48-
self.button2.on_click = self.set_text
48+
self.button2.onClick = self.set_text
4949

5050
self.show()
5151

5252
def get_text(self):
53-
print(self.textbox.get_text())
53+
print(self.textbox.getText())
5454

5555
def set_text(self):
56-
self.textbox.set_text('1234567890')
56+
self.textbox.setText('1234567890')
5757

5858
TextBoxDialog()

0 commit comments

Comments
 (0)