так грустно, что на этом форуме нет помощи, нет предложений, нет подсказок :( Я провел еще несколько исследований и пытался перевести из C# источников, я придумал этот код, но все еще не работает. шанс получить помощь?
import clr
import System
clr.AddReference("System.Windows.Forms")
clr.AddReference("System.Drawing")
from System.Windows.Forms import Form, Application, Label, Button, Binding, BindingSource, FormBorderStyle, ComboBox
from System.Drawing import Size, Point, Font
data1 = """
job_number=001
job_name=Henderson
job_address=34 Henderson Street, Henderson
building_usage=Garage
costumer_name=John Doe
"""
data2 = """
job_number=002
job_name=Glen Dale
job_address=70 Fleet Street
building_usage=Hangar
costumer_name=Unknown
"""
class obj(System.Object):
def __init__(self, name, text):
self._name = name
self._text = text
@property
def Name(self):
return self._name
@property
def Text(self):
return self._text
def toDict(mylist):
mylist = mylist.split('\n')
odict = {}
klist = []
olist = []
for i in mylist:
if i != '' and i != ' ':
key = str(i.split('=')[0].replace('"', ''))
val = str(i.split('=')[1].replace('"', ''))
klist.append(key)
ob = obj(key, val)
olist.append(ob)
odict = dict(zip(klist, olist))
return odict
global dictionary
dictionary = toDict(data1)
class MyForm(Form):
def __init__(self):
# Main Form
self.ClientSize = Size(300, 200)
self.CenterToScreen()
self.Text = "MyForm"
self.FormBorderStyle = FormBorderStyle.FixedDialog
font = Font("Arial", 14)
# ComboBox1
comboBox1 = ComboBox()
comboBox1.Text = dictionary["job_name"].Name
comboBox1.Font = font
comboBox1.Location = Point(30, 10)
comboBox1.Size = Size(190,90)
self.Controls.Add(comboBox1)
button = Button()
button.Text = "Update"
comboBox1.Location = Point(30, 40)
button.Click += self.update
self.Controls.Add(button)
# Label1
label1 = Label()
label1.Text = dictionary["job_name"].Text
label1.Font = font
label1.Location = Point(30, 70)
label1.Size = Size(190,90)
self.Controls.Add(label1)
# Binding
bs = BindingSource()
bs.DataSource = dictionary
comboBox1.DataSource = bs
comboBox1.DataMember = dictionary["job_name"]
label1.DataBindings.Add("Text", dictionary, dictionary["job_name"])
# Actions
def update(self, sender, event):
global dictionary
dictionary = toDict(data2)
dialog = MyForm()
Application.Run(dialog)