def _initializeUserInterface(self):
     self.Size = Size(1600, 500)
     self.tlpMain.ColumnCount = len(self.columnNames)
     self.tlpMain.RowCount = 2
     self.tlpMain.Size = self.ClientRectangle.Size
     #create list titles
     for name in self.columnNames:
         lbl = Label()
         lbl.Text = name
         lbl.Font = Font("Microsoft Sans Serif", 12, FontStyle.Bold)
         lbl.Height = 50
         self.tlpMain.Controls.Add(lbl)
     #create lists
     for name in self.columnNames:
         lst = ListBox()
         lst.Name = name
         lst.Font = Font("Microsoft Sans Serif", 10)
         lst.Width = 135
         if name.ToLower() == 'attribute':
             lst.Width = 300
         if name.ToLower() == 'mode':
             lst.Width = 215
         lst.Height = self.ClientRectangle.Height - (lbl.Height * 2)
         self.tlpMain.Controls.Add(lst)
         self._populateLists(lst)
Exemple #2
0
def popup(text):
    form = Form()
    form.StartPosition = FormStartPosition.CenterScreen
    form.Width = 300
    form.Height = 300
    form.Text = 'Mais pas tout le temps'
    label = Label()
    label.Text = text
    label.Width = 300
    label.Height = 300
    label.Parent = form
    form.ShowDialog()
#Input form

if isinstance(IN[0], list):
    inputnames = IN[0]
else:
    inputnames = [IN[0]]

if isinstance(IN[1], list):
    inputtypes = IN[1]
else:
    inputtypes = [IN[1]]

for i, j in zip(inputnames, inputtypes):
    label = Label()
    label.Location = Point(xlabel, y + 4 * resfactY)
    label.Height = 20 * resfactY
    label.Width = 80 * resfactX
    label.Text = str(i)
    form.Controls.Add(label)
    if isinstance(j, list):
        cb = ComboBox()
        cb.Location = Point(xinput, y)
        cb.Width = 150 * resfactX
        globals()['dict%d' % (cbindex)] = {}
        try:
            for k in j:
                globals()['dict%d' % (cbindex)][k.Name] = k
                cb.Items.Add(k.Name)
        except:
            for k in j:
                try:
	def __init__(self):
		self.patient = patient
		self.Text = 'My Form' #title of the new format
		self.AutoSize = True
		labelX1 = Label()
		labelX2 = Label()
		labelX1.Text = 'What is'
		labelX2.Text = 'this?'
		labelX1.Location = Point(15,28)
		labelX2.Location = Point(120,28)
		labelX1.Width = 50
		labelX2.Width = 50
		labelX1.Height = 20
		labelX2.Height = 40
		self.Controls.Add(labelX1)
		self.Controls.Add(labelX2)
		# create a textbox property of the form
		self.textbox1 = TextBox()
		self.textbox1.Location = Point(50,200)
		self.textbox1.Width = 120
		self.textbox1.Height = 50
		self.Controls.Add(self.textbox1)
		# implement an interaction button
		self.button1 = Button()
		self.button1.Text = "Auto-fill current patient name"
		self.button1.Location = Point(50, 120)
		self.button1.Width = 150
		self.button1.Height = 45
		self.Controls.Add(self.button1)
		self.button1.Click += self.button1_clicked
		# add checklist question
		self.question1 = Label()
		self.question1.Text = "Which actions have you finished so far?"
		self.question1.Location = Point(15,280)
		self.question1.AutoSize = True
		self.Controls.Add(self.question1)
		# first checkbox
		self.check1 = CheckBox()
		self.check1.Text = "Patient modelling"
		self.check1.Location = Point(20,310)
		self.check1.AutoSize = True
		self.check1.Checked = False
		self.Controls.Add(self.check1)
		self.check1.CheckedChanged += self.checkedChanged
		# second checkbox
		self.check2 = CheckBox()
		self.check2.Text = "Plan design"
		self.check2.Location = Point(20,340)
		self.check2.AutoSize = True
		self.check2.Checked = False
		self.Controls.Add(self.check2)
		self.check2.CheckedChanged += self.checkedChanged
		# add checklist response message
		self.response1 = Label()
		self.response1.Text = "-"
		self.response1.Location = Point(160,340)
		self.response1.AutoSize = True
		self.Controls.Add(self.response1)
		# generate combobox
		self.question2 = Label()
		self.question2.Text = "Select an ROI"
		self.question2.Location = Point(320,310)
		self.question2.AutoSize = True
		self.Controls.Add(self.question2)
		rois = [r.Name for r in patient.PatientModel.RegionsOfInterest]
		self.combobox = ComboBox()
		self.combobox.Location = Point(320,340)
		self.combobox.DataSource = rois
		self.Controls.Add(self.combobox)
		self.combobox.SelectionChangeCommitted += self.comboSelection
		# generate combobox response
		self.response2 = Label()
		self.response2.Text = ""
		self.response2.Location = Point(320,380)
		self.response2.AutoSize = True
		self.Controls.Add(self.response2)
Exemple #5
0
 def __init__(self):
     self.patient = patient
     self.Text = 'My Form'  #title of the new format
     self.AutoSize = True
     labelX1 = Label()
     labelX2 = Label()
     labelX1.Text = 'What is'
     labelX2.Text = 'this?'
     labelX1.Location = Point(15, 28)
     labelX2.Location = Point(120, 28)
     labelX1.Width = 50
     labelX2.Width = 50
     labelX1.Height = 20
     labelX2.Height = 40
     self.Controls.Add(labelX1)
     self.Controls.Add(labelX2)
     # create a textbox property of the form
     self.textbox1 = TextBox()
     self.textbox1.Location = Point(50, 200)
     self.textbox1.Width = 120
     self.textbox1.Height = 50
     self.Controls.Add(self.textbox1)
     # implement an interaction button
     self.button1 = Button()
     self.button1.Text = "Auto-fill current patient name"
     self.button1.Location = Point(50, 120)
     self.button1.Width = 150
     self.button1.Height = 45
     self.Controls.Add(self.button1)
     self.button1.Click += self.button1_clicked
     # add checklist question
     self.question1 = Label()
     self.question1.Text = "Which actions have you finished so far?"
     self.question1.Location = Point(15, 280)
     self.question1.AutoSize = True
     self.Controls.Add(self.question1)
     # first checkbox
     self.check1 = CheckBox()
     self.check1.Text = "Patient modelling"
     self.check1.Location = Point(20, 310)
     self.check1.AutoSize = True
     self.check1.Checked = False
     self.Controls.Add(self.check1)
     self.check1.CheckedChanged += self.checkedChanged
     # second checkbox
     self.check2 = CheckBox()
     self.check2.Text = "Plan design"
     self.check2.Location = Point(20, 340)
     self.check2.AutoSize = True
     self.check2.Checked = False
     self.Controls.Add(self.check2)
     self.check2.CheckedChanged += self.checkedChanged
     # add checklist response message
     self.response1 = Label()
     self.response1.Text = "-"
     self.response1.Location = Point(160, 340)
     self.response1.AutoSize = True
     self.Controls.Add(self.response1)
     # generate combobox
     self.question2 = Label()
     self.question2.Text = "Select an ROI"
     self.question2.Location = Point(320, 310)
     self.question2.AutoSize = True
     self.Controls.Add(self.question2)
     rois = [r.Name for r in patient.PatientModel.RegionsOfInterest]
     self.combobox = ComboBox()
     self.combobox.Location = Point(320, 340)
     self.combobox.DataSource = rois
     self.Controls.Add(self.combobox)
     self.combobox.SelectionChangeCommitted += self.comboSelection
     # generate combobox response
     self.response2 = Label()
     self.response2.Text = ""
     self.response2.Location = Point(320, 380)
     self.response2.AutoSize = True
     self.Controls.Add(self.response2)
Exemple #6
0
def clicked(sender, args):
    global count
    global button
    count += 1
    button.Text = "Clicked %s times" % count


a = Form()
a.Text = "Hi"
a.Name = "Hi"

label = Label()
label.Text = "lel"
label.Location = Point(50, 50)
label.Height = 30
label.Width = 200
a.Controls.Add(label)

button = Button()
button.Text = "yeman"
button.Location = Point(100, 100)
button.Height = 30
button.Width = 50
button.Click += clicked
a.Controls.Add(button)

Application.Run(a)

# window = Tk()
# window.title("Tagme")
    def __init__(self):
        self.received_messages = {}
        self.msg_ids = {}

        self.config = None
        self.num_messages = DEFAULT_NUM_MESSAGES
        if path.exists(CONFIG_FILENAME):
            print('Reading config...')
            self.config = open(CONFIG_FILENAME, 'r').readlines()
            for x in range(len(self.config)):
                self.config[x] = self.config[x].strip('\n')
            self.num_messages = int(self.config[0].split(',')[0])

        # we subscribe to every possible MAVLink message here
        # super inefficient, but much easier to just collect 'em all!
        for attr_name in dir(MAVLink.MAVLINK_MSG_ID):
            if attr_name.upper() == attr_name:
                attr = getattr(MAVLink.MAVLINK_MSG_ID, attr_name)
                self.msg_ids[attr.value__] = attr
                MAV.SubscribeToPacketType(
                    attr, Func[MAVLink.MAVLinkMessage,
                               bool](self.get_message_data))
        MAV.OnPacketReceived += self.packet_handler

        self.Text = 'MAVLink MinMonitor'
        self.Location = Point(0, 0)
        self.TopMost = True
        self.BackColor = CustomColor.MPDarkGray
        self.ForeColor = CustomColor.White
        self.Shown += self.on_load
        self.FormClosing += self.on_exit

        self.margin = 5
        start_x, start_y = 12, 10

        self.msg_widgets = []
        for x in range(self.num_messages):
            cbo_msg_id = ComboBox()
            cbo_msg_id.Width = 175
            cbo_msg_id.DropDownStyle = ComboBoxStyle.DropDown
            cbo_msg_id.FlatStyle = FlatStyle.Flat
            cbo_msg_id.BackColor = CustomColor.MPLightGray
            cbo_msg_id.ForeColor = CustomColor.White
            cbo_msg_id.DataSource = self.received_messages.keys()
            cbo_msg_id.MouseDown += self.update_message_ids
            cbo_msg_id.SelectionChangeCommitted += self.update_datasource
            cbo_msg_id.Text = ''

            cbo_msg_dataframes = ComboBox()
            cbo_msg_dataframes.Width = 120
            cbo_msg_dataframes.DropDownStyle = ComboBoxStyle.DropDown
            cbo_msg_dataframes.FlatStyle = FlatStyle.Flat
            cbo_msg_dataframes.BackColor = CustomColor.MPLightGray
            cbo_msg_dataframes.ForeColor = CustomColor.White
            cbo_msg_dataframes.Text = ''

            lbl_data = Label()
            lbl_data.Text = 'NO DATA'
            lbl_data.BackColor = CustomColor.MPMediumGray
            lbl_data.Width = 120
            lbl_data.Height = cbo_msg_id.Height - 5

            txt_min = TextBox()
            txt_min.Width = 75
            txt_min.BorderStyle = BorderStyle.FixedSingle
            txt_min.BackColor = CustomColor.MPLightGray
            txt_min.ForeColor = CustomColor.White
            txt_min.MaxLength = 10
            txt_min.TextAlign = HorizontalAlignment.Center
            txt_min.KeyPress += self.limit_to_decimal_digits

            txt_max = TextBox()
            txt_max.Width = 75
            txt_max.BorderStyle = BorderStyle.FixedSingle
            txt_max.BackColor = CustomColor.MPLightGray
            txt_max.ForeColor = CustomColor.White
            txt_max.MaxLength = 10
            txt_max.TextAlign = HorizontalAlignment.Center
            txt_max.KeyPress += self.limit_to_decimal_digits

            txt_factor = TextBox()
            txt_factor.Width = 75
            txt_factor.BorderStyle = BorderStyle.FixedSingle
            txt_factor.BackColor = CustomColor.MPLightGray
            txt_factor.ForeColor = CustomColor.White
            txt_factor.MaxLength = 10
            txt_factor.TextAlign = HorizontalAlignment.Center
            txt_factor.KeyPress += self.limit_to_decimal_digits

            self.msg_widgets.append(
                OrderedDict([('cbo_msg_id', cbo_msg_id),
                             ('cbo_msg_dataframes', cbo_msg_dataframes),
                             ('lbl_data', lbl_data), ('txt_min', txt_min),
                             ('txt_max', txt_max),
                             ('txt_factor', txt_factor)]))

        self.lbl_min = Label()
        self.lbl_min.Text = 'Min'
        self.lbl_min.BackColor = CustomColor.MPDarkGray
        self.lbl_min.Width = self.msg_widgets[0]['txt_min'].Width
        self.lbl_min.Height = self.msg_widgets[0]['txt_min'].Height - 5

        self.lbl_max = Label()
        self.lbl_max.Text = 'Max'
        self.lbl_max.BackColor = CustomColor.MPDarkGray
        self.lbl_max.Width = self.msg_widgets[0]['txt_max'].Width
        self.lbl_max.Height = self.msg_widgets[0]['txt_max'].Height - 5

        self.lbl_factor = Label()
        self.lbl_factor.Text = 'Factor'
        self.lbl_factor.BackColor = CustomColor.MPDarkGray
        self.lbl_factor.Width = self.msg_widgets[0]['txt_factor'].Width
        self.lbl_factor.Height = self.msg_widgets[0]['txt_factor'].Height - 5

        self.lbl_num_messages = Label()
        self.lbl_num_messages.Text = 'Number of messages to monitor (restart to take effect)'
        self.lbl_num_messages.BackColor = CustomColor.MPDarkGray
        self.lbl_num_messages.AutoSize = True

        self.spn_num_messages = NumericUpDown()
        self.spn_num_messages.Width = 40
        self.spn_num_messages.BorderStyle = BorderStyle.FixedSingle
        self.spn_num_messages.BackColor = CustomColor.MPLightGray
        self.spn_num_messages.ForeColor = CustomColor.White
        self.spn_num_messages.Value = self.num_messages

        self.chk_hide_factors = CheckBox()
        self.chk_hide_factors.FlatAppearance.BorderSize = 1
        self.chk_hide_factors.FlatAppearance.BorderColor = CustomColor.MPLightGray
        self.chk_hide_factors.Text = 'Hide threshold/scaling preferences'
        self.chk_hide_factors.AutoSize = True

        self.chk_sticky = CheckBox()
        self.chk_sticky.FlatAppearance.BorderSize = 1
        self.chk_sticky.FlatAppearance.BorderColor = CustomColor.MPLightGray
        self.chk_sticky.Text = 'Always on top'
        self.chk_sticky.AutoSize = True

        self.lbl_status = Label()
        self.lbl_status.Text = 'No messages received'
        self.lbl_status.BackColor = CustomColor.MPMediumGray
        self.lbl_status.Height = self.msg_widgets[0]['txt_min'].Height - 5

        # pseudo-responsive form layout
        x, y = start_x, start_y
        max_x = 0
        x = start_x + (self.msg_widgets[0]['cbo_msg_id'].Width +
                       self.msg_widgets[0]['cbo_msg_dataframes'].Width +
                       self.msg_widgets[0]['lbl_data'].Width) + self.margin * 4
        x, y, x_extent = \
            self.add_control_horizontal(self.lbl_min, x, y, self.margin)
        x, y, x_extent = \
            self.add_control_horizontal(self.lbl_max, x, y, self.margin)
        x, y, x_extent = \
            self.add_control_vertical(self.lbl_factor, x, y, self.margin)
        for widget in self.msg_widgets:
            x = start_x
            for control in widget.items():
                x, y, x_extent = self.add_control_horizontal(
                    control[1], x, y, self.margin)
            max_x = max([x_extent, max_x])
            y += widget.items()[0][1].Height + self.margin
        self.Width = max_x + self.margin * 4
        self.WideWidth = self.Width
        self.NarrowWidth = self.msg_widgets[0]['lbl_data'].Location.X + \
                           self.msg_widgets[0]['lbl_data'].Width + self.margin * 5
        y += 20
        x, y, x_extent = self.add_control_horizontal(self.spn_num_messages,
                                                     start_x, y, self.margin)
        x, y, x_extent = self.add_control_vertical(self.lbl_num_messages, x,
                                                   y + 3, self.margin)
        x, y, x_extent = self.add_control_vertical(self.chk_hide_factors,
                                                   start_x + 3, y + 5,
                                                   self.margin)
        x, y, x_extent = self.add_control_vertical(self.chk_sticky, x, y,
                                                   self.margin)
        self.lbl_status.Width = self.Width - self.margin * 7
        x, y, x_extent = self.add_control_vertical(self.lbl_status, start_x,
                                                   y + 3, self.margin)
        self.Height = y + self.lbl_status.Height + self.margin * 5