-
Notifications
You must be signed in to change notification settings - Fork 0
/
t-dialog.py
79 lines (65 loc) · 2.22 KB
/
t-dialog.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import sys
sys.path.insert(1, 'far3-installed')
from far3.far3cffi import ffi, ffic
from far3 import pluginmanager
from far3 import fardialogbuilder as dlgb
import os
cwd = os.getcwd().encode('ascii')
fcwd = ffi.new("char []", cwd)
pluginmanager.PySetup(fcwd)
def s2f(s):
return ffi.new("wchar_t []", s)
def f2s(s):
return ffi.string(ffi.cast("wchar_t *", s))
class Info:
def Message(self, guid1, guid2, Flags, HelpTopic, Items, ItemsNumber, ButtonsNumber):
print('Message', guid1, guid2, Flags, HelpTopic, Items, ItemsNumber, ButtonsNumber
)
return 0
def SendDlgMessage(self, hdlg, cmd, p1, p2):
print('SendDlgMessage', hdlg, cmd, p1, p2)
s = s2f('result abc')
return s
def DialogInit(self, guid1, guid2, x1, y1, x2, y2, HelpTopic, Item, ItemsNumber, Reserved, Flags, DlgProc, Param):
print('DialogInit', guid1, guid2, x1, y1, x2, y2, HelpTopic, Item, ItemsNumber, Reserved, Flags, DlgProc, Param
)
return 12345678
def DialogRun(self, hDlg):
print('DialogRun', hDlg)
return 0
def DialogFree(self, hDlg):
print('DialogFree', hDlg)
def main():
info = Info()
from far3 import upythonconfig
cls = upythonconfig.Plugin(info)
#cls.OpenW(None)
@ffi.callback("FARWINDOWPROC")
def DialogProc(hDlg, Msg, Param1, Param2):
return self.info.DefDlgProc(hDlg, Msg, Param1, Param2)
dlg = dlgb.Dialog(cls)
# { DI_DOUBLEBOX, L-2,1, E+2,2+H, 0, nullptr,nullptr, 0, title.c_str() },
b = dlgb.DialogBuilder(
dlg,
DialogProc,
"Python path",
"pythonpath",
0,
dlgb.VSizer(
dlgb.HSizer(
dlgb.TEXT(None, text="Python path:"),
dlgb.EDIT("path", width=60, maxlength=120)
),
dlgb.HSizer(
dlgb.BUTTON('vok', text="OK", flags=ffic.DIF_DEFAULTBUTTON|ffic.DIF_CENTERGROUP),
dlgb.BUTTON('vcancel', text="Cancel", flags=ffic.DIF_CENTERGROUP),
),
),
)
b.build(-1, -1)
dlg.SetText(dlg.ID_path, 'abc')
res = dlg.Info.DialogRun(dlg.hDlg)
path = dlg.GetText(dlg.ID_path)
print('DialogRun={}, path={}'.format(res, path))
dlg.close()
main()