-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample_fix-advanced-oil-processing-forms.py
More file actions
101 lines (73 loc) · 2.84 KB
/
example_fix-advanced-oil-processing-forms.py
File metadata and controls
101 lines (73 loc) · 2.84 KB
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
#
# generated by wxGlade 1.0.4 on Tue Nov 7 16:49:05 2023
#
import wx
from bp_from_json import blueprint
# begin wxGlade: dependencies
# end wxGlade
# begin wxGlade: extracode
# end wxGlade
################################################################
def fix_recipe(book):
for bp in book.get_all_bp(onedimensional=True, blueprint_only=True):
for entity in bp.get_entities():
if "oil-refinery" in entity.read_name():
if entity.read_recipe() == "basic-oil-processing":
entity.set("recipe", "advanced-oil-processing")
################################################################
class MyFrame(wx.Frame):
def __init__(self, *args, **kwds):
# begin wxGlade: MyFrame.__init__
kwds["style"] = kwds.get("style", 0) | wx.DEFAULT_FRAME_STYLE
wx.Frame.__init__(self, *args, **kwds)
self.SetSize((800, 600))
self.SetTitle("frame")
self.panel_1 = wx.Panel(self, wx.ID_ANY)
sizer_1 = wx.BoxSizer(wx.VERTICAL)
# self.text_ctrl_1 = wx.TextCtrl(self.panel_1, wx.ID_ANY, "", style=wx.TE_RICH2)
# sizer_1.Add(self.text_ctrl_1, 10, wx.EXPAND, 0)
self.button_1 = wx.Button(self.panel_1, wx.ID_ANY, "button_1")
sizer_1.Add(self.button_1, 0, 0, 0)
self.text_ctrl_2 = wx.TextCtrl(self.panel_1, wx.ID_ANY, "", style=wx.TE_RICH2)
sizer_1.Add(self.text_ctrl_2, 10, wx.EXPAND, 0)
self.panel_1.SetSizer(sizer_1)
self.Layout()
self.Bind(wx.EVT_BUTTON, self.button_1_on_click, self.button_1)
# end wxGlade
def button_1_on_click(self, event): # wxGlade: MyFrame.<event_handler>
print()
# Читаем текст
text = ""
if wx.TheClipboard.Open():
if wx.TheClipboard.IsSupported(wx.DataFormat(wx.DF_UNICODETEXT)):
data = wx.TextDataObject()
if wx.TheClipboard.GetData(data):
text = data.GetText()
else:
text = ""
wx.TheClipboard.Close()
# print(text)
bp = blueprint.from_string(text)
fix_recipe(bp)
text = bp.to_str()
self.text_ctrl_2.AppendText("copied {}\n".format(len(text)))
if wx.TheClipboard.Open():
if wx.TheClipboard.IsSupported(wx.DataFormat(wx.DF_UNICODETEXT)):
data = wx.TextDataObject()
data.SetText(text)
wx.TheClipboard.SetData(data)
wx.TheClipboard.Close()
event.Skip()
# end of class MyFrame
class MyApp(wx.App):
def OnInit(self):
self.MainWin = MyFrame(None, wx.ID_ANY, "")
self.SetTopWindow(self.MainWin)
self.MainWin.Show()
return True
# end of class MyApp
if __name__ == "__main__":
app = MyApp(0)
app.MainLoop()