Esempio n. 1
0
    def ShowDialog(self, controller, title, text, default_input, exp_index):
        # set controller
        self.controller = controller

        # set exp index
        self.exp_index = exp_index

        # initialize exp name variable
        self.exp_name = None

        # initialize invalid name label
        self.invalid_name_label = None

        # create the form
        self.dialog_window = Form()
        self.dialog_window.AutoSize = True
        self.dialog_window.Width = 400
        self.dialog_window.MaximumSize = Size(400, 160)
        self.dialog_window.StartPosition = FormStartPosition.CenterScreen
        self.dialog_window.Text = title
        self.dialog_window.FormBorderStyle = FormBorderStyle.FixedSingle

        # create the main panel
        self.panel = FlowLayoutPanel()
        self.panel.Parent = self.dialog_window
        self.panel.BackColor = DIALOG_COLOR
        self.panel.Dock = DockStyle.Top
        self.panel.Padding = Padding(10, 10, 0, 10)
        self.panel.FlowDirection = FlowDirection.TopDown
        self.panel.WrapContents = False
        self.panel.AutoSize = True
        self.panel.Font = BODY_FONT

        # add the dialog text
        exp_name_label = Label()
        exp_name_label.Parent = self.panel
        exp_name_label.Text = text
        exp_name_label.Width = self.panel.Width
        exp_name_label.AutoSize = True
        exp_name_label.Margin = Padding(0, 5, 0, 0)

        # add the textbox
        self.exp_name_box = TextBox()
        self.exp_name_box.Text = default_input
        self.exp_name_box.Parent = self.panel
        self.exp_name_box.Width = self.panel.Width - 30
        self.exp_name_box.AutoSize = True
        self.exp_name_box.BackColor = BUTTON_PANEL_COLOR
        self.exp_name_box.Font = Font(BODY_FONT.FontFamily, 9)

        # add save button panel
        self.add_save_button_panel()

        # show the dialog
        self.dialog_window.ShowDialog()

        # return the exp name
        return self.exp_name
Esempio n. 2
0
def add_param_label(text, panel):
    # add param label
    label = Label()
    label.Parent = panel
    label.Text = text
    label.AutoSize = True
    label.Font = BODY_FONT
    label.Margin = Padding(0, 5, 0, 0)
    label.Width = panel.Width
Esempio n. 3
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()
    def ShowDialog(self, controller, title, text):
        # set controller
        self.controller = controller

        # create confirmation boolean -- True means the user wants to save
        # the stimulus settings and stop the currently running stimulation.
        self.confirmation = False

        # create the form
        self.dialog_window = Form()
        self.dialog_window.AutoSize = True
        self.dialog_window.Width = 400
        self.dialog_window.MaximumSize = Size(400, 225)
        self.dialog_window.StartPosition = FormStartPosition.CenterScreen
        self.dialog_window.Text = title
        self.dialog_window.FormBorderStyle = FormBorderStyle.FixedSingle

        # create the main panel
        self.panel = FlowLayoutPanel()
        self.panel.Parent = self.dialog_window
        self.panel.BackColor = DIALOG_COLOR
        self.panel.Dock = DockStyle.Top
        self.panel.Padding = Padding(10, 10, 0, 10)
        self.panel.FlowDirection = FlowDirection.TopDown
        self.panel.WrapContents = False
        self.panel.AutoSize = True
        self.panel.Font = BODY_FONT

        # add the dialog text
        dialog_label = Label()
        dialog_label.Parent = self.panel
        dialog_label.Text = text
        dialog_label.Width = self.panel.Width
        dialog_label.AutoSize = True
        dialog_label.Margin = Padding(0, 5, 0, 0)

        # add button panel
        self.add_button_panel()

        # show the dialog
        self.dialog_window.ShowDialog()

        # return the exp name
        return self.confirmation
Esempio n. 5
0
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:
                    globals()['dict%d' % (cbindex)][str(k)] = k
	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)
Esempio n. 7
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)
Esempio n. 8
0
	def __init__(self):
	
		FORMheight = 250 
		FORMwidth = 400

		self.Text = 'Whatsapp Import - Whatsapp messages loader'
		self.Height = FORMheight-50
		self.Width = FORMwidth


		flowPanel = FlowLayoutPanel()
		flowPanel.AutoSize = True
		flowPanel.AutoSizeMode = AutoSizeMode.GrowAndShrink
		self.Controls.Add(flowPanel)

		labelDir = Label()
		labelDir.Text = "Exported artifacts directory path:"
		labelDir.Top = 20
		labelDir.Left = 10
		labelDir.Width = 300
		labelDir.Anchor = AnchorStyles.Top

		TextboxDir = TextBox()
		TextboxDir.Name = 'ImportDir'
		TextboxDir.Text = '\export'#[type directory]'
		TextboxDir.Top = 45
		TextboxDir.Left = 10
		TextboxDir.Width = 360
		TextboxDir.Anchor = AnchorStyles.Top

		'''labelRegex = Label()
		labelRegex.Text = "Chat file's name regex:"
		labelRegex.Top = 75
		labelRegex.Left = 10
		labelRegex.Width = 300
		labelRegex.Anchor = AnchorStyles.Top

		fileRegex = TextBox()
		fileRegex.Name = 'fileNameRegex'
		fileRegex.Text = '^Conversa\sdo\sWhatsApp\scom\s(.*)\.txt$'
		fileRegex.Top = 100
		fileRegex.Left = 10
		fileRegex.Width = 360
		fileRegex.Anchor = AnchorStyles.Top'''

		'''SelectDirBtn = Button()
		SelectDirBtn.Text = 'Select dir.'		
		SelectDirBtn.Width = 150		
		SelectDirBtn.Top = 80
		SelectDirBtn.Left = 350
		SelectDirBtn.UseVisualStyleBackColor = True
		SelectDirBtn.Anchor = AnchorStyles.Top
		SelectDirBtn.Click += self.onClick'''

		button = Button()
		button.Text = "Import"
		button.Width = 110
		button.Top = 120
		button.Left = (FORMwidth / 2) - 50
		button.Anchor = AnchorStyles.Top
		button.Click += self.buttonPressed
		
		self.Controls.Add(labelDir)
		self.Controls.Add(TextboxDir)
		#self.Controls.Add(labelRegex)
		#self.Controls.Add(fileRegex)
		#self.Controls.Add(SelectDirBtn)
		self.Controls.Add(button)
Esempio n. 9
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")
# window.geometry("500x500")
Esempio n. 10
0
    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