Example #1
0
    def setupPanel2(self):
        self.panel2 = Panel()
        # self.panel2.Text = "Panel"
        self.panel2.Width = self.Width
        self.panel2.Height = 120
        self.panel2.Location = Point(0, 120)
        self.panel2.BorderStyle = BorderStyle.FixedSingle

        self.p2title1 = Label()
        self.p2title1.Text = "Create Lumped Port"
        self.p2title1.Location = Point(25, 22)
        self.p2title1.Height = 25
        self.p2title1.AutoSize = True

        self.p2label1 = Label()
        self.p2label1.Text = "Ground Metal Name: "
        self.p2label1.Location = Point(25, 50)
        self.p2label1.Height = 25
        self.p2label1.Width = 150

        self.p2button1 = Button()
        self.p2button1.Text = 'Create'
        self.p2button1.Location = Point(25, 75)
        self.p2button1.Width = 100
        self.p2button1.Click += self.p2update

        self.p2button2 = Button()
        self.p2button2.Text = 'Reset'
        self.p2button2.Location = Point(180, 75)
        self.p2button2.Width = 100
        self.p2button2.Click += self.p2reset

        self.p2list1 = ComboBox()
        self.p2list1.Text = '——Select'
        self.p2list1.Location = Point(180, 47)
        self.p2list1.Width = 100
        self.p2list1.Height = 35
        self.DropDownHeight = 50
        self.p2list1.Click += self.p2listUpdate

        self.AcceptButton = self.p2button1
        self.CancelButton = self.p2button2

        self.panel2.Controls.Add(self.p2title1)
        self.panel2.Controls.Add(self.p2label1)
        self.panel2.Controls.Add(self.p2button1)
        self.panel2.Controls.Add(self.p2button2)
        self.panel2.Controls.Add(self.p2list1)
Example #2
0
    def __init__(self, items):
        self.exEvent = None
        self.Width = 360
        self.Height = 140
        self.combo_box = ComboBox()
        self.combo_box.Width = 300
        self.combo_box.Location = Point(20, 30)
        items = list(items)
        items.sort()
        for i in items:
            self.combo_box.Items.Add(i)
        self.combo_box.SelectedIndex = 0
        self.label = Label()
        self.label.Text = "Выберете лист на который нужно добавить текущий вид"
        self.label.Width = 400
        self.label.Location = Point(20, 10)

        self.button = Button()
        self.button.Width = 300
        self.button.Text = "Расположить"
        self.button.Location = Point(20, 60)
        self.button.Click += self.run
        self.Controls.Add(self.combo_box)
        self.Controls.Add(self.label)
        self.Controls.Add(self.button)
Example #3
0
    def __init__(self, posx, posy, hight, width, title, curvlaue, values,
                 name):
        # print( width ,"^^^^^^^^^^^^^^^")
        self._Padding = 3
        super(ComboCtrlview, self).__init__(self)
        self._Values = values
        self.Notify = None
        self.curvalue = ""
        self.ctrlwidth = (width - self._Padding) / 2
        self.Size = Size(width, hight)
        self.Location = Point(posx, posy)
        self.name = name

        self.Font = self.getFont()

        self.label = Label()
        self.label.Parent = self
        self.label.Text = title
        self.label.Font = self.Font
        self.label.Location = Point(0, 0)
        self.label.Size = Size(self.ctrlwidth, hight)
        self.label.TextAlign = ContentAlignment.MiddleRight

        self.cb = ComboBox()
        self.cb.Parent = self
        self.cb.Items.AddRange(self._Values)
        if len(curvlaue) > 0:
            self.cb.Text = curvlaue
        self.cb.Font = self.Font
        self.cb.ForeColor = Color.Blue
        self.cb.SelectedValueChanged += self.OnChanged
        self.cb.DropDown += self.TextUpdate

        self.cb.Location = Point(self.label.Right + self._Padding, 0)
        self.cb.Size = Size(self.ctrlwidth, hight)
    def __init__(self):
        """ComboBoxSample class init function."""

        # setup title
        self.Text = "ComboBox Style Changes"
        self.Width = 400
        self.Height = 500
        self.is_x10 = False

        # setup buttons
        self.dropdownlistbutton = Button()
        self.dropdownlistbutton.Text = "DropDownList"
        self.dropdownlistbutton.Width = 110
        self.dropdownlistbutton.Location = Point(5, 5)
        self.dropdownlistbutton.Click += self.change_to_dropdownlist

        self.dropdownbutton = Button()
        self.dropdownbutton.Text = "DropDown"
        self.dropdownbutton.Width = 110
        self.dropdownbutton.Location = Point(135, 5)
        self.dropdownbutton.Click += self.change_to_dropdown
        self.dropdownbutton.BackColor = Color.Lime

        self.simplebutton = Button()
        self.simplebutton.Text = "Simple"
        self.simplebutton.Width = 110
        self.simplebutton.Location = Point(265, 5)
        self.simplebutton.Click += self.change_to_simple

        self.xtenbutton = Button()
        self.xtenbutton.Text = "Toggle x10"
        self.xtenbutton.Width = 110
        self.xtenbutton.Location = Point(5, 55)
        self.xtenbutton.Click += self.toggle_x10

        # setup label
        self.label = Label()
        self.label.Text = "You select "
        self.label.Location = Point(5, 100)

        # setup combobox
        self.combobox = ComboBox()
        self.combobox.DropDownStyle = ComboBoxStyle.DropDown
        self.combobox.SelectionChangeCommitted += self.select
        self.combobox.TextChanged += self.select
        self.combobox.Width = 390
        self.combobox.Location = Point(0, 130)

        # add items in ComboBox
        for i in range(10):
            self.combobox.Items.Add(str(i))
        self.combobox.SelectedIndex = 1

        # add controls
        self.Controls.Add(self.combobox)
        self.Controls.Add(self.label)
        self.Controls.Add(self.dropdownlistbutton)
        self.Controls.Add(self.dropdownbutton)
        self.Controls.Add(self.simplebutton)
        self.Controls.Add(self.xtenbutton)
Example #5
0
    def __init__(self):
        """ComboBoxSample class init function."""

        # setup title
        self.Text = "ComboBox control"
        self.Height = 400

        # setup label
        self.label = Label()
        self.label.Text = "You select "
        self.label.AutoSize = True
        self.label.Dock = DockStyle.Top

        # setup combobox
        self.combobox = ComboBox()
        self.combobox.Dock = DockStyle.Top
        self.combobox.SelectionChangeCommitted += self.select
        self.combobox.DropDownStyle = ComboBoxStyle.Simple
        self.combobox.SelectedIndexChanged += self.select
        self.combobox.Height = 300

        # add items in ComboBox
        for i in range(10):
            self.combobox.Items.Add(str(i))

        # add controls
        self.Controls.Add(self.combobox)
        self.Controls.Add(self.label)
Example #6
0
    def setupPanel1(self):
        self.panel1 = Panel()
        self.panel1.Width = self.Width
        self.panel1.Height = 120
        self.panel1.Location = Point(0, 0)
        self.panel1.BorderStyle = BorderStyle.FixedSingle

        self.title1 = Label()
        self.title1.Text = "ReAssign Terminal"
        self.title1.Location = Point(25, 22)
        self.title1.Height = 25
        self.title1.AutoSize = True

        self.label2 = Label()
        self.label2.Text = "Ground Metal Name: "
        self.label2.Location = Point(25, 50)
        self.label2.Height = 25
        self.label2.Width = 150

        self.button1 = Button()
        self.button1.Text = 'Assign'
        self.button1.Location = Point(25, 75)
        self.button1.Width = 100
        self.button1.Click += self.update

        self.button2 = Button()
        self.button2.Text = 'Reset'
        self.button2.Location = Point(180, 75)
        self.button2.Width = 100
        self.button2.Click += self.reset

        self.list1 = ComboBox()
        self.list1.Text = '——Select'
        self.list1.Location = Point(180, 47)
        self.list1.Width = 100
        self.list1.Height = 35
        self.DropDownHeight = 50
        self.list1.Click += self.listUpdate

        self.AcceptButton = self.button1
        self.CancelButton = self.button2

        self.panel1.Controls.Add(self.label2)
        self.panel1.Controls.Add(self.title1)
        self.panel1.Controls.Add(self.button1)
        self.panel1.Controls.Add(self.button2)
        self.panel1.Controls.Add(self.list1)
Example #7
0
    def __init__(self):
        self.fm = doc.FamilyManager
        self._all_param_names = None

        self.Text = 'Параметры'
        self.Name = 'Select Parameters'
        self.Width = 400
        self.Height = 450

        self.title = Label()
        self.title.Text = "Выберете параметры"
        self.title.Height = 30
        self.title.TextAlign = ContentAlignment.MiddleCenter
        self.title.Dock = DockStyle.Top

        self.label = Label()
        self.label.Text = "Выберете новую группу параметров"
        self.label.Height = 30
        self.label.TextAlign = ContentAlignment.MiddleCenter
        self.label.Dock = DockStyle.Top

        self.listbox = ListBox()
        self.listbox.MultiColumn = False
        self.listbox.SelectionMode = SelectionMode.MultiExtended
        self.listbox.BeginUpdate()
        params = list(self.all_param_names.keys())
        params.sort()
        for i in params:
            self.listbox.Items.Add(i)
        self.listbox.EndUpdate()
        self.listbox.Height = 270
        self.listbox.Location = Point(0, 30)
        self.listbox.Dock = DockStyle.Top

        self.combobox = ComboBox()
        els = list(self.all_param_group.keys())
        els.sort()
        for i in els:
            self.combobox.Items.Add(i)
        self.combobox.Location = Point(0, 300)
        self.combobox.Dock = DockStyle.Top

        self.button = Button()
        self.button.Text = "Перенести"
        self.button.Dock = DockStyle.Top
        self.button.Click += self.change_param_group

        self.Controls.Add(self.button)
        self.Controls.Add(self.combobox)
        self.Controls.Add(self.label)
        self.Controls.Add(self.listbox)
        self.Controls.Add(self.title)

        self.handler = Execute_change_group()
        self.exEvent = ExternalEvent.Create(self.handler)
Example #8
0
    def __init__(self):

        self.Text = "ComboBox"
        self.Size = Size(240, 240)

        cb = ComboBox()
        cb.Parent = self
        cb.Location = Point(50, 30)

        cb.Items.AddRange(
            ("Ubuntu", "Mandriva", "Red Hat", "Fedora", "Gentoo"))

        cb.SelectionChangeCommitted += self.OnChanged

        self.label = Label()
        self.label.Location = Point(50, 140)
        self.label.Parent = self
        self.label.Text = "..."

        self.CenterToScreen()
Example #9
0
    def __init__(self):
        self.Text = 'ListBox'
        name = ColumnHeader()
        name.Text = 'Name'
        name.Width = -1
        year = ColumnHeader()
        year.Text = 'Type'
        year.Width = -1

        cb = ComboBox()
        #cb.Parent = self
        #cb.Location = Point(50, 30)

        cb.Items.AddRange(
            ("Ubuntu", "Mandriva", "Red Hat", "Fedora", "Gentoo"))

        cb.SelectionChangeCommitted += self.OnChanged

        self.SuspendLayout()

        lv = ListView()
        lv.Parent = self
        lv.FullRowSelect = True
        lv.GridLines = True
        lv.AllowColumnReorder = True
        lv.Sorting = SortOrder.Ascending
        lv.Columns.AddRange((name, year))
        lv.ColumnClick += self.OnColumnClick

        # for act in actresses.keys():
        # item = ListViewItem()
        # item.Text = act
        # item.SubItems.Add(str(actresses[act]))
        # lv.Items.Add(item)
        for f in familyfiles:
            item = ListViewItem()
            item.Text = f
            item.SubItems.Add("Family File")
            lv.Items.Add(item)

        lv.Dock = DockStyle.Fill
        lv.Click += self.OnChanged

        self.sb = StatusBar()
        self.sb.Parent = self
        lv.View = View.Details

        self.ResumeLayout()

        self.Size = Size(850, 800)
        self.CenterToScreen()
    def __init__(self):

        self.Text = "ComboBox"
        self.Size = Size(240, 240)

        cb = ComboBox()
        cb.Parent = self
        cb.Location = Point(50, 30)

        cb.Items.AddRange(("Ubuntu",
            "Mandriva",
            "Red Hat",
            "Fedora",
            "Gentoo"))

        cb.SelectionChangeCommitted += self.OnChanged

        self.label = Label()
        self.label.Location = Point(50, 140)
        self.label.Parent = self
        self.label.Text = "..."


        self.CenterToScreen()
Example #11
0
    def __init__(self, param):
        super(PanelParameter, self).__init__()

        self.Height = Fconfig.unitline
        self.paramtype = param[1]
        tooltips = ToolTip()
        self.value = ''

        self.textlabel = Label()
        self.textlabel.Parent = self
        self.textlabel.Text = '{0} ({1}) :'.format(param[0], param[1])
        self.textlabel.Location = Point(0, 0)
        self.textlabel.Size = Size(Fconfig.lblwidth, Fconfig.unitline)
        self.textlabel.TextAlign = ContentAlignment.MiddleLeft

        #ComboBox if list
        if len(param) >= 3:
            self.textbox = ComboBox()
            list_items = List[Object](param[2])
            self.textbox.Items.AddRange(list_items.ToArray())

            #dropdownstyle with 4th param if False:
            if len(param) > 3 and not param[3]:
                self.textbox.DropDownStyle = ComboBoxStyle.DropDownList
                self.textbox.SelectionChangeCommitted += self.onInput

        #else simple textbox
        else:
            self.textbox = TextBox()

        self.textbox.Parent = self
        self.textbox.Location = Point(self.textlabel.Right + Fconfig.margin,
                                      10)
        self.textbox.Width = Fconfig.smwidth - self.textlabel.Width - 2 * Fconfig.margin
        self.textbox.TextChanged += self.onInput

        tooltips.SetToolTip(self.textbox, Types.types(param[1], 'tooltip'))

        ModeDBG.say('panel {0}, top {1}, height :{2}'.format(
            param[1], self.Top, self.Height))
Example #12
0
    def populate_stim_choice_panel(self):
        # empty stim choice panel
        list_of_controls = self.stim_choice_panel.Controls
        for control in list_of_controls:
            control.Dispose()
        self.stim_choice_panel.Controls.Clear()

        # add stim choice label
        stim_choice_label = Label()
        stim_choice_label.Parent = self.stim_choice_panel
        stim_choice_label.Text = "Stim:"
        stim_choice_label.AutoSize = True

        # add stim chooser
        self.stim_chooser = ComboBox()
        self.stim_chooser.DropDownStyle = ComboBoxStyle.DropDownList
        self.stim_chooser.Parent = self.stim_choice_panel
        self.stim_chooser.Items.AddRange(("Looming Dot", "Moving Dot", "Combined Dots", "Optomotor Grating", "Grating", "Broadband Grating", "Delay", "Black Flash", "White Flash"))  ##!! need to add option for OKR here
        self.stim_chooser.SelectionChangeCommitted += self.on_stim_choice
        self.stim_chooser.Text = self.stim_type
        self.stim_chooser.Width = self.dialog_window.Width - 40
        self.stim_chooser.AutoSize = True
        self.stim_chooser.Font = BODY_FONT
Example #13
0
    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
                except:
                    globals()['dict%d' %
                              (cbindex)][k.encode('utf-8').decode('utf-8')] = k
                cb.Items.Add(k)
Example #14
0
    def __init__(self, tools):

        label_width = 30
        offset = 30
        index = 0

        # header
        self.Text = "Add layer"
        width = 400

        #label

        #textInput
        # labelstart = Label(Text="Text at start", AutoSize=True)
        # labelstart.Location = Point(label_width, offset* index)
        # self.Controls.Add(labelstart)
        # pt.X = labelstart.Right + offset
        # inputstart = TextBox(Text="Start")
        # inputstart.Location = pt
        # self.Controls.Add(inputstart)
        # if( inputstart.Right > width ):
        # width = inputstart.Right
        # self.m_inputstart = inputstart

        # TOOL SELECTON
        index += 1
        cbb = ComboBox(
            Text="Outer contour",
            Location=Point(label_width, offset * index),
            Parent=self,
            Width=200,
        )
        cbb.Items.AddRange(
            ("Inner contour", "Outer contour", "Pocket", "Engrave", "Drill",
             "Saw X", "Saw Y", "Clamex verticaal", "Clamex horizontaal"))
        cbb.TextChanged += self.updateLabelLayername
        self.cbb_operation = cbb

        # TOOL SELECTON
        index += 1
        cbb = ComboBox(Text=tools[0],
                       Location=Point(label_width, offset * index),
                       Parent=self,
                       Width=200)
        cbb.Items.AddRange(tools)
        cbb.TextChanged += self.updateLabelLayername

        self.cbb_tool = cbb

        index += 1
        sb = NumericUpDown(AutoSize=True,
                           Location=Point(label_width, offset * index),
                           Parent=self,
                           DecimalPlaces=2)
        sb.ValueChanged += self.updateLabelLayername

        self.sb_height = sb

        index += 1
        cb = CheckBox(Text="use depth from top of workpiece",
                      AutoSize=True,
                      Location=Point(label_width, offset * index),
                      Parent=self)
        cb.Checked = False
        cb.CheckedChanged += self.updateLabelLayername

        self.cb_depth = cb

        index += 1
        la = Label(Text="<layername>",
                   Location=Point(label_width, offset * index),
                   Parent=self,
                   AutoSize=True)
        self.la_layername = la

        index += 1
        pt = Point(label_width, offset * index)

        buttonApply = Button(Text="Apply", DialogResult=DialogResult.OK)
        buttonApply.Location = pt
        self.Controls.Add(buttonApply)
        pt.X = buttonApply.Right + offset
        buttonCancel = Button(Text="Cancel", DialogResult=DialogResult.Cancel)
        buttonCancel.Location = pt
        self.Controls.Add(buttonCancel)
        if (buttonCancel.Right > width):
            width = buttonCancel.Right
        self.ClientSize = Size(width, buttonCancel.Bottom + 10)
        self.AcceptButton = buttonApply
        self.CancelButton = buttonCancel
        def setupPlanningScriptLauncher(self):
            self.LauncherPanel = self.newPanel(0, 0)

            self.PatientLabel = Label()
            self.PatientLabel.Text = "Patient: " + patient.PatientName.replace(
                '^', ', ')
            self.PatientLabel.Location = Point(25, 25)
            self.PatientLabel.Font = Font("Arial", 10, FontStyle.Bold)
            self.PatientLabel.AutoSize = True

            self.Label2 = Label()
            self.Label2.Text = ""
            self.Label2.Location = Point(300, 50)
            self.Label2.AutoSize = True
            self.Label2.Font = Font("Arial", 10)
            self.Label2.ForeColor = Color.Black

            self.Label3 = Label()
            self.Label3.Text = ""
            self.Label3.Location = Point(300, 70)
            self.Label3.AutoSize = True
            self.Label3.Font = Font("Arial", 10)
            self.Label3.ForeColor = Color.Black

            self.Label4 = Label()
            self.Label4.Text = ""
            self.Label4.Location = Point(300, 90)
            self.Label4.AutoSize = True
            self.Label4.Font = Font("Arial", 10)
            self.Label4.ForeColor = Color.Black

            self.Label5 = Label()
            self.Label5.Text = ""
            self.Label5.Location = Point(300, 110)
            self.Label5.AutoSize = True
            self.Label5.Font = Font("Arial", 10)
            self.Label5.ForeColor = Color.Black

            self.Reminder = Label()
            self.Reminder.Text = ""
            self.Reminder.Location = Point(300, 220)
            self.Reminder.AutoSize = True
            self.Reminder.Font = Font("Arial", 11, FontStyle.Italic)
            self.Reminder.ForeColor = Color.Black

            self.PTV1Label = Label()
            self.PTV1Label.Text = "PTV 1 (+haut):"
            self.PTV1Label.Location = Point(25, 60)
            self.PTV1Label.Font = Font("Arial", 10)
            self.PTV1Label.AutoSize = True

            self.PTV1name = TextBox()
            self.PTV1name.Text = " "
            self.PTV1name.Size = Size(60, 60)
            self.PTV1name.Location = Point(120, 60)

            self.dose1Label = Label()
            self.dose1Label.Text = "dose:"
            self.dose1Label.Location = Point(200, 60)
            self.dose1Label.Font = Font("Arial", 10)
            self.dose1Label.AutoSize = True

            self.PTV1dose = TextBox()
            self.PTV1dose.Text = " "
            self.PTV1dose.Size = Size(40, 30)
            self.PTV1dose.Location = Point(260, 60)

            self.fractionLabel = Label()
            self.fractionLabel.Text = "nbr fraction:"
            self.fractionLabel.Location = Point(320, 60)
            self.fractionLabel.Font = Font("Arial", 10)
            self.fractionLabel.AutoSize = True

            self.fraction = TextBox()
            self.fraction.Text = " "
            self.fraction.Size = Size(40, 30)
            self.fraction.Location = Point(430, 60)

            self.PTV2Label = Label()
            self.PTV2Label.Text = "PTV 2:"
            self.PTV2Label.Location = Point(25, 90)
            self.PTV2Label.Font = Font("Arial", 10)
            self.PTV2Label.AutoSize = True

            self.PTV2name = TextBox()
            self.PTV2name.Text = " "
            self.PTV2name.Size = Size(60, 60)
            self.PTV2name.Location = Point(120, 90)

            self.dose2Label = Label()
            self.dose2Label.Text = "dose:"
            self.dose2Label.Location = Point(200, 90)
            self.dose2Label.Font = Font("Arial", 10)
            self.dose2Label.AutoSize = True

            self.PTV2dose = TextBox()
            self.PTV2dose.Text = " "
            self.PTV2dose.Size = Size(40, 30)
            self.PTV2dose.Location = Point(260, 90)

            self.champLabel = Label()
            self.champLabel.Text = "nbr champs/arcs:"
            self.champLabel.Location = Point(320, 90)
            self.champLabel.Font = Font("Arial", 10)
            self.champLabel.AutoSize = True

            self.champ = TextBox()
            self.champ.Text = " "
            self.champ.Size = Size(40, 30)
            self.champ.Location = Point(430, 90)

            self.PTV3Label = Label()
            self.PTV3Label.Text = "PTV 3:"
            self.PTV3Label.Location = Point(25, 120)
            self.PTV3Label.Font = Font("Arial", 10)
            self.PTV3Label.AutoSize = True

            self.PTV3name = TextBox()
            self.PTV3name.Text = " "
            self.PTV3name.Size = Size(60, 60)
            self.PTV3name.Location = Point(120, 120)

            self.dose3Label = Label()
            self.dose3Label.Text = "dose:"
            self.dose3Label.Location = Point(200, 120)
            self.dose3Label.Font = Font("Arial", 10)
            self.dose3Label.AutoSize = True

            self.PTV3dose = TextBox()
            self.PTV3dose.Text = " "
            self.PTV3dose.Size = Size(40, 30)
            self.PTV3dose.Location = Point(260, 120)

            self.avertissement = Label()
            self.avertissement.Text = "(2 arcs maximum):"
            self.avertissement.Location = Point(320, 110)
            self.avertissement.Font = Font("Arial", 8)
            self.avertissement.AutoSize = True

            self.PTV4Label = Label()
            self.PTV4Label.Text = "PTV 4:"
            self.PTV4Label.Location = Point(25, 150)
            self.PTV4Label.Font = Font("Arial", 10)
            self.PTV4Label.AutoSize = True

            self.PTV4name = TextBox()
            self.PTV4name.Text = " "
            self.PTV4name.Size = Size(60, 60)
            self.PTV4name.Location = Point(120, 150)

            self.dose4Label = Label()
            self.dose4Label.Text = "dose:"
            self.dose4Label.Location = Point(200, 150)
            self.dose4Label.Font = Font("Arial", 10)
            self.dose4Label.AutoSize = True

            self.PTV4dose = TextBox()
            self.PTV4dose.Text = " "
            self.PTV4dose.Size = Size(40, 30)
            self.PTV4dose.Location = Point(260, 150)

            self.techniqueLabel = Label()
            self.techniqueLabel.Text = "Technique:"
            self.techniqueLabel.Location = Point(25, 180)
            self.techniqueLabel.Font = Font("Arial", 10)
            self.techniqueLabel.AutoSize = True

            self.techniquecombo = ComboBox()
            self.techniquecombo.Parent = self
            self.techniquecombo.Size = Size(55, 40)
            self.techniquecombo.Location = Point(135, 180)
            self.techniquecombo.Items.Add("IMRT")
            self.techniquecombo.Items.Add("VMAT")
            self.techniquecombo.Text = 'IMRT'

            self.SiteLabel = Label()
            self.SiteLabel.Text = "Nom du site:"
            self.SiteLabel.Location = Point(25, 210)
            self.SiteLabel.Font = Font("Arial", 10)
            self.SiteLabel.AutoSize = True

            self.SiteBox = TextBox()
            self.SiteBox.Text = "A1"
            self.SiteBox.Location = Point(135, 210)
            self.SiteBox.Width = 40

            self.scanLabel = Label()
            self.scanLabel.Text = "Scan de planif"
            self.scanLabel.Location = Point(25, 240)
            self.scanLabel.Font = Font("Arial", 10)
            self.scanLabel.AutoSize = True

            self.scancombo = ComboBox()
            self.scancombo.Parent = self
            self.scancombo.Size = Size(55, 40)
            self.scancombo.Location = Point(135, 240)
            self.scancombo.Text = 'Choissisez'

            self.OptionsLabel = Label()
            self.OptionsLabel.Text = "Options:"
            self.OptionsLabel.Location = Point(25, 300)
            self.OptionsLabel.Font = Font("Arial", 10)
            self.OptionsLabel.AutoSize = True

            self.check1 = CheckBox()
            self.check1.Text = "Double optimization initiale + extra?"
            self.check1.Location = Point(40, 330)
            self.check1.Width = 300
            self.check1.Checked = False

            self.check3 = CheckBox()
            self.check3.Text = "Inclure structures optiques?"
            self.check3.Location = Point(40, 360)
            self.check3.Width = 300
            self.check3.Checked = False

            self.check2 = CheckBox()
            self.check2.Text = "Adapter dose color table?"
            self.check2.Location = Point(40, 390)
            self.check2.Width = 300
            self.check2.Checked = True

            self.Entete = Label()
            self.Entete.Text = ""
            self.Entete.Location = Point(300, 25)
            self.Entete.AutoSize = True
            self.Entete.Font = Font("Arial", 12, FontStyle.Bold)
            self.Entete.ForeColor = Color.Black

            self.LauncherPanel.Controls.Add(self.PatientLabel)
            self.LauncherPanel.Controls.Add(self.Label2)
            self.LauncherPanel.Controls.Add(self.Label3)
            self.LauncherPanel.Controls.Add(self.Label4)
            self.LauncherPanel.Controls.Add(self.Label5)
            self.LauncherPanel.Controls.Add(self.Entete)
            self.LauncherPanel.Controls.Add(self.Reminder)
            #self.LauncherPanel.Controls.Add(self.RxLabel)
            self.LauncherPanel.Controls.Add(self.PTV1Label)
            self.LauncherPanel.Controls.Add(self.PTV1name)
            self.LauncherPanel.Controls.Add(self.dose1Label)
            self.LauncherPanel.Controls.Add(self.PTV1dose)
            self.LauncherPanel.Controls.Add(self.PTV2Label)
            self.LauncherPanel.Controls.Add(self.PTV2name)
            self.LauncherPanel.Controls.Add(self.dose2Label)
            self.LauncherPanel.Controls.Add(self.PTV2dose)
            self.LauncherPanel.Controls.Add(self.PTV3Label)
            self.LauncherPanel.Controls.Add(self.PTV3name)
            self.LauncherPanel.Controls.Add(self.dose3Label)
            self.LauncherPanel.Controls.Add(self.PTV3dose)
            self.LauncherPanel.Controls.Add(self.PTV4Label)
            self.LauncherPanel.Controls.Add(self.PTV4name)
            self.LauncherPanel.Controls.Add(self.dose4Label)
            self.LauncherPanel.Controls.Add(self.PTV4dose)
            self.LauncherPanel.Controls.Add(self.fractionLabel)
            self.LauncherPanel.Controls.Add(self.fraction)
            #self.LauncherPanel.Controls.Add(self.isodoseLabel)
            self.LauncherPanel.Controls.Add(self.scanLabel)
            self.LauncherPanel.Controls.Add(self.techniqueLabel)
            self.LauncherPanel.Controls.Add(self.champLabel)
            self.LauncherPanel.Controls.Add(self.champ)
            self.LauncherPanel.Controls.Add(self.avertissement)
            self.LauncherPanel.Controls.Add(self.SiteLabel)
            self.LauncherPanel.Controls.Add(self.SiteBox)
            self.LauncherPanel.Controls.Add(self.OptionsLabel)
            self.LauncherPanel.Controls.Add(self.check1)
            self.LauncherPanel.Controls.Add(self.check2)
            self.LauncherPanel.Controls.Add(self.check3)
            #self.LauncherPanel.Controls.Add(self.check3)

            exam_list = []
            for CT in patient.Examinations:
                exam_list.append(CT.Name)

            for contour in patient.PatientModel.RegionsOfInterest:
                if not roi.get_roi_approval(contour.Name,
                                            patient.Examinations["CT 1"]):
                    VolCT1 = roi.get_roi_volume(
                        contour.Name, exam=patient.Examinations["CT 1"])
                    if "CT 2" in exam_list:
                        VolCT2 = roi.get_roi_volume(
                            contour.Name, exam=patient.Examinations["CT 2"])
                    else:
                        VolCT2 = 0

                    if VolCT1 == 0 and VolCT2 == 0:
                        contour.Name = ("vide_" + contour.Name)

            self.trouvePTV()
    class ScriptLauncher(Form):
        def __init__(self):
            self.Text = "ORL Script Launcher"

            self.Width = 750
            self.Height = 780

            self.setupPlanningScriptLauncher()
            self.setupOKButtons()
            self.setupMachineSelectPanel()

            self.Controls.Add(self.LauncherPanel)
            self.Controls.Add(self.OKbuttonPanel)
            self.Controls.Add(self.MachineSelectPanel)

        def newPanel(self, x, y):
            panel = Panel()
            panel.Width = 750
            panel.Height = 450
            panel.Location = Point(x, y)
            panel.BorderStyle = BorderStyle.None
            return panel

        def miniPanel(self, x, y):
            panel = Panel()
            panel.Width = 750
            panel.Height = 130
            panel.Location = Point(x, y)
            panel.BorderStyle = BorderStyle.None
            return panel

        def setupPlanningScriptLauncher(self):
            self.LauncherPanel = self.newPanel(0, 0)

            self.PatientLabel = Label()
            self.PatientLabel.Text = "Patient: " + patient.PatientName.replace(
                '^', ', ')
            self.PatientLabel.Location = Point(25, 25)
            self.PatientLabel.Font = Font("Arial", 10, FontStyle.Bold)
            self.PatientLabel.AutoSize = True

            self.Label2 = Label()
            self.Label2.Text = ""
            self.Label2.Location = Point(300, 50)
            self.Label2.AutoSize = True
            self.Label2.Font = Font("Arial", 10)
            self.Label2.ForeColor = Color.Black

            self.Label3 = Label()
            self.Label3.Text = ""
            self.Label3.Location = Point(300, 70)
            self.Label3.AutoSize = True
            self.Label3.Font = Font("Arial", 10)
            self.Label3.ForeColor = Color.Black

            self.Label4 = Label()
            self.Label4.Text = ""
            self.Label4.Location = Point(300, 90)
            self.Label4.AutoSize = True
            self.Label4.Font = Font("Arial", 10)
            self.Label4.ForeColor = Color.Black

            self.Label5 = Label()
            self.Label5.Text = ""
            self.Label5.Location = Point(300, 110)
            self.Label5.AutoSize = True
            self.Label5.Font = Font("Arial", 10)
            self.Label5.ForeColor = Color.Black

            self.Reminder = Label()
            self.Reminder.Text = ""
            self.Reminder.Location = Point(300, 220)
            self.Reminder.AutoSize = True
            self.Reminder.Font = Font("Arial", 11, FontStyle.Italic)
            self.Reminder.ForeColor = Color.Black

            self.PTV1Label = Label()
            self.PTV1Label.Text = "PTV 1 (+haut):"
            self.PTV1Label.Location = Point(25, 60)
            self.PTV1Label.Font = Font("Arial", 10)
            self.PTV1Label.AutoSize = True

            self.PTV1name = TextBox()
            self.PTV1name.Text = " "
            self.PTV1name.Size = Size(60, 60)
            self.PTV1name.Location = Point(120, 60)

            self.dose1Label = Label()
            self.dose1Label.Text = "dose:"
            self.dose1Label.Location = Point(200, 60)
            self.dose1Label.Font = Font("Arial", 10)
            self.dose1Label.AutoSize = True

            self.PTV1dose = TextBox()
            self.PTV1dose.Text = " "
            self.PTV1dose.Size = Size(40, 30)
            self.PTV1dose.Location = Point(260, 60)

            self.fractionLabel = Label()
            self.fractionLabel.Text = "nbr fraction:"
            self.fractionLabel.Location = Point(320, 60)
            self.fractionLabel.Font = Font("Arial", 10)
            self.fractionLabel.AutoSize = True

            self.fraction = TextBox()
            self.fraction.Text = " "
            self.fraction.Size = Size(40, 30)
            self.fraction.Location = Point(430, 60)

            self.PTV2Label = Label()
            self.PTV2Label.Text = "PTV 2:"
            self.PTV2Label.Location = Point(25, 90)
            self.PTV2Label.Font = Font("Arial", 10)
            self.PTV2Label.AutoSize = True

            self.PTV2name = TextBox()
            self.PTV2name.Text = " "
            self.PTV2name.Size = Size(60, 60)
            self.PTV2name.Location = Point(120, 90)

            self.dose2Label = Label()
            self.dose2Label.Text = "dose:"
            self.dose2Label.Location = Point(200, 90)
            self.dose2Label.Font = Font("Arial", 10)
            self.dose2Label.AutoSize = True

            self.PTV2dose = TextBox()
            self.PTV2dose.Text = " "
            self.PTV2dose.Size = Size(40, 30)
            self.PTV2dose.Location = Point(260, 90)

            self.champLabel = Label()
            self.champLabel.Text = "nbr champs/arcs:"
            self.champLabel.Location = Point(320, 90)
            self.champLabel.Font = Font("Arial", 10)
            self.champLabel.AutoSize = True

            self.champ = TextBox()
            self.champ.Text = " "
            self.champ.Size = Size(40, 30)
            self.champ.Location = Point(430, 90)

            self.PTV3Label = Label()
            self.PTV3Label.Text = "PTV 3:"
            self.PTV3Label.Location = Point(25, 120)
            self.PTV3Label.Font = Font("Arial", 10)
            self.PTV3Label.AutoSize = True

            self.PTV3name = TextBox()
            self.PTV3name.Text = " "
            self.PTV3name.Size = Size(60, 60)
            self.PTV3name.Location = Point(120, 120)

            self.dose3Label = Label()
            self.dose3Label.Text = "dose:"
            self.dose3Label.Location = Point(200, 120)
            self.dose3Label.Font = Font("Arial", 10)
            self.dose3Label.AutoSize = True

            self.PTV3dose = TextBox()
            self.PTV3dose.Text = " "
            self.PTV3dose.Size = Size(40, 30)
            self.PTV3dose.Location = Point(260, 120)

            self.avertissement = Label()
            self.avertissement.Text = "(2 arcs maximum):"
            self.avertissement.Location = Point(320, 110)
            self.avertissement.Font = Font("Arial", 8)
            self.avertissement.AutoSize = True

            self.PTV4Label = Label()
            self.PTV4Label.Text = "PTV 4:"
            self.PTV4Label.Location = Point(25, 150)
            self.PTV4Label.Font = Font("Arial", 10)
            self.PTV4Label.AutoSize = True

            self.PTV4name = TextBox()
            self.PTV4name.Text = " "
            self.PTV4name.Size = Size(60, 60)
            self.PTV4name.Location = Point(120, 150)

            self.dose4Label = Label()
            self.dose4Label.Text = "dose:"
            self.dose4Label.Location = Point(200, 150)
            self.dose4Label.Font = Font("Arial", 10)
            self.dose4Label.AutoSize = True

            self.PTV4dose = TextBox()
            self.PTV4dose.Text = " "
            self.PTV4dose.Size = Size(40, 30)
            self.PTV4dose.Location = Point(260, 150)

            self.techniqueLabel = Label()
            self.techniqueLabel.Text = "Technique:"
            self.techniqueLabel.Location = Point(25, 180)
            self.techniqueLabel.Font = Font("Arial", 10)
            self.techniqueLabel.AutoSize = True

            self.techniquecombo = ComboBox()
            self.techniquecombo.Parent = self
            self.techniquecombo.Size = Size(55, 40)
            self.techniquecombo.Location = Point(135, 180)
            self.techniquecombo.Items.Add("IMRT")
            self.techniquecombo.Items.Add("VMAT")
            self.techniquecombo.Text = 'IMRT'

            self.SiteLabel = Label()
            self.SiteLabel.Text = "Nom du site:"
            self.SiteLabel.Location = Point(25, 210)
            self.SiteLabel.Font = Font("Arial", 10)
            self.SiteLabel.AutoSize = True

            self.SiteBox = TextBox()
            self.SiteBox.Text = "A1"
            self.SiteBox.Location = Point(135, 210)
            self.SiteBox.Width = 40

            self.scanLabel = Label()
            self.scanLabel.Text = "Scan de planif"
            self.scanLabel.Location = Point(25, 240)
            self.scanLabel.Font = Font("Arial", 10)
            self.scanLabel.AutoSize = True

            self.scancombo = ComboBox()
            self.scancombo.Parent = self
            self.scancombo.Size = Size(55, 40)
            self.scancombo.Location = Point(135, 240)
            self.scancombo.Text = 'Choissisez'

            self.OptionsLabel = Label()
            self.OptionsLabel.Text = "Options:"
            self.OptionsLabel.Location = Point(25, 300)
            self.OptionsLabel.Font = Font("Arial", 10)
            self.OptionsLabel.AutoSize = True

            self.check1 = CheckBox()
            self.check1.Text = "Double optimization initiale + extra?"
            self.check1.Location = Point(40, 330)
            self.check1.Width = 300
            self.check1.Checked = False

            self.check3 = CheckBox()
            self.check3.Text = "Inclure structures optiques?"
            self.check3.Location = Point(40, 360)
            self.check3.Width = 300
            self.check3.Checked = False

            self.check2 = CheckBox()
            self.check2.Text = "Adapter dose color table?"
            self.check2.Location = Point(40, 390)
            self.check2.Width = 300
            self.check2.Checked = True

            self.Entete = Label()
            self.Entete.Text = ""
            self.Entete.Location = Point(300, 25)
            self.Entete.AutoSize = True
            self.Entete.Font = Font("Arial", 12, FontStyle.Bold)
            self.Entete.ForeColor = Color.Black

            self.LauncherPanel.Controls.Add(self.PatientLabel)
            self.LauncherPanel.Controls.Add(self.Label2)
            self.LauncherPanel.Controls.Add(self.Label3)
            self.LauncherPanel.Controls.Add(self.Label4)
            self.LauncherPanel.Controls.Add(self.Label5)
            self.LauncherPanel.Controls.Add(self.Entete)
            self.LauncherPanel.Controls.Add(self.Reminder)
            #self.LauncherPanel.Controls.Add(self.RxLabel)
            self.LauncherPanel.Controls.Add(self.PTV1Label)
            self.LauncherPanel.Controls.Add(self.PTV1name)
            self.LauncherPanel.Controls.Add(self.dose1Label)
            self.LauncherPanel.Controls.Add(self.PTV1dose)
            self.LauncherPanel.Controls.Add(self.PTV2Label)
            self.LauncherPanel.Controls.Add(self.PTV2name)
            self.LauncherPanel.Controls.Add(self.dose2Label)
            self.LauncherPanel.Controls.Add(self.PTV2dose)
            self.LauncherPanel.Controls.Add(self.PTV3Label)
            self.LauncherPanel.Controls.Add(self.PTV3name)
            self.LauncherPanel.Controls.Add(self.dose3Label)
            self.LauncherPanel.Controls.Add(self.PTV3dose)
            self.LauncherPanel.Controls.Add(self.PTV4Label)
            self.LauncherPanel.Controls.Add(self.PTV4name)
            self.LauncherPanel.Controls.Add(self.dose4Label)
            self.LauncherPanel.Controls.Add(self.PTV4dose)
            self.LauncherPanel.Controls.Add(self.fractionLabel)
            self.LauncherPanel.Controls.Add(self.fraction)
            #self.LauncherPanel.Controls.Add(self.isodoseLabel)
            self.LauncherPanel.Controls.Add(self.scanLabel)
            self.LauncherPanel.Controls.Add(self.techniqueLabel)
            self.LauncherPanel.Controls.Add(self.champLabel)
            self.LauncherPanel.Controls.Add(self.champ)
            self.LauncherPanel.Controls.Add(self.avertissement)
            self.LauncherPanel.Controls.Add(self.SiteLabel)
            self.LauncherPanel.Controls.Add(self.SiteBox)
            self.LauncherPanel.Controls.Add(self.OptionsLabel)
            self.LauncherPanel.Controls.Add(self.check1)
            self.LauncherPanel.Controls.Add(self.check2)
            self.LauncherPanel.Controls.Add(self.check3)
            #self.LauncherPanel.Controls.Add(self.check3)

            exam_list = []
            for CT in patient.Examinations:
                exam_list.append(CT.Name)

            for contour in patient.PatientModel.RegionsOfInterest:
                if not roi.get_roi_approval(contour.Name,
                                            patient.Examinations["CT 1"]):
                    VolCT1 = roi.get_roi_volume(
                        contour.Name, exam=patient.Examinations["CT 1"])
                    if "CT 2" in exam_list:
                        VolCT2 = roi.get_roi_volume(
                            contour.Name, exam=patient.Examinations["CT 2"])
                    else:
                        VolCT2 = 0

                    if VolCT1 == 0 and VolCT2 == 0:
                        contour.Name = ("vide_" + contour.Name)

            self.trouvePTV()

        def trouvePTV(self):

            # Erase error messages and clear prescription selection menu
            self.Label2.Text = ""
            self.Label3.Text = ""
            self.Label4.Text = ""
            self.Label5.Text = ""
            #self.Entete.Text = "test DM"
            self.Reminder.Text = ""
            self.Label2.ForeColor = Color.Black
            self.Label3.ForeColor = Color.Black
            self.Label4.ForeColor = Color.Black
            self.Label5.ForeColor = Color.Black
            #self.Entete.ForeColor = Color.Black
            #self.Reminder.ForeColor = Color.Black
            #self.check1.Text = "Double optimization initiale + extra?"
            #self.check1.Checked = False
            #self.check2.Text = ""
            #self.check2.Checked = False
            #self.check3.Text = ""
            #self.check3.Checked = False
            #self.comboBoxRx.Items.Clear()
            #self.comboBoxRx.Text = "-----"
            #self.techniquecombo.Items.Clear()
            #self.techniquecombo.Items.Add("VMAT")
            #self.techniquecombo.Text = 'VMAT'
            PACE = False

            roi_names = [
                x.Name for x in patient.PatientModel.RegionsOfInterest
            ]
            ptv_name_list = []
            presc_dose_list = []

            for name in roi_names:
                n = name.replace(' ', '').upper()
                debut = name[0:3]
                if debut == 'PTV':
                    try:
                        presc_dose = float(name[3:])
                    except IndexError:
                        continue
                    except ValueError:
                        continue
                    ptv_name_list.append(name)
                    presc_dose_list.append(presc_dose)

            ptv_name_list.sort(reverse=True)
            presc_dose_list.sort(reverse=True)

            if len(ptv_name_list) == 0:
                self.Label2.Text = "Attention: Aucun PTV trouvé!"
                self.Label2.ForeColor = Color.Red
            else:
                self.PTV1name.Text = ptv_name_list[0]
                self.PTV1dose.Text = '%.2f' % presc_dose_list[0]
                try:
                    self.PTV2name.Text = ptv_name_list[1]
                    self.PTV2dose.Text = '%.2f' % presc_dose_list[1]
                except IndexError:
                    pass
                try:
                    self.PTV3name.Text = ptv_name_list[2]
                    self.PTV3dose.Text = '%.2f' % presc_dose_list[2]
                except IndexError:
                    pass
                try:
                    self.PTV4name.Text = ptv_name_list[3]
                    self.PTV4dose.Text = '%.2f' % presc_dose_list[3]
                except IndexError:
                    pass

        def okClicked(self, sender, args):
            #Prevent users from creating a new plan twice in a row
            if self.Status.Text == "Script terminé! Cliquez sur Cancel pour sortir.":
                return

            #Check to see which machine is selected for treatment
            if self.BeamModButton.Checked:
                machine = 'BeamMod'
            elif self.InfinityButton.Checked:
                machine = 'Infinity'
            else:
                self.Status.Text = "Il faut choisir un appareil avant de continuer"
                self.Status.ForeColor = Color.Red
                return

            #Check treatment techniqueLabel and nbr of field

            if self.techniquecombo.Text == 'IMRT':
                treatment_technique = 'SMLC'
                beamset_name = 'ORL IMRT'
            else:
                treatment_technique = 'VMAT'
                beamset_name = 'ORL VMAT'

            #Determine prescription dose (in Gy) and number of fractions

            rx_dose = []
            ptv = []

            try:
                rx_dose_PTV1 = int(float(self.PTV1dose.Text) * 100)
                rx_dose.append(rx_dose_PTV1)
                ptv.append(self.PTV1name.Text)
            except ValueError:
                pass
            try:
                rx_dose_PTV2 = int(float(self.PTV2dose.Text) * 100)
                rx_dose.append(rx_dose_PTV2)
                ptv.append(self.PTV2name.Text)
            except ValueError:
                pass
            try:
                rx_dose_PTV3 = int(float(self.PTV3dose.Text) * 100)
                rx_dose.append(rx_dose_PTV3)
                ptv.append(self.PTV3name.Text)
            except ValueError:
                pass
            try:
                rx_dose_PTV4 = int(float(self.PTV4dose.Text) * 100)
                rx_dose.append(rx_dose_PTV4)
                ptv.append(self.PTV4name.Text)
            except ValueError:
                pass

            try:
                nb_fx = int(self.fraction.Text)
            except ValueError:
                self.Status.Text = "Impossible de lire le nombre de fractions"
                self.Status.ForeColor = Color.Red

            try:
                nb_ch = int(self.champ.Text)
            except ValueError:
                self.Status.Text = "Impossible de lire le nombre de champ"
                self.Status.ForeColor = Color.Red

            #Create the plan data dictionary to send to the component scripts
            #d = {'plan_name':'A1'}
            d = dict(patient=patient,
                     plan_name=beamset_name,
                     beamset_name=beamset_name,
                     site_name=self.SiteBox.Text,
                     exam=patient.Examinations[self.scancombo.Text],
                     ct=self.scancombo.Text,
                     machine=machine,
                     nb_fx=nb_fx,
                     nb_ch=nb_ch,
                     rx_dose=rx_dose,
                     ptv=ptv,
                     treatment_technique=treatment_technique)

            self.Status.ForeColor = Color.Black

            if patient.BodySite == '':
                patient.BodySite = 'ORL'
            #POIS assignation, ROIS creation, plan and beamset adding
            self.Status.Text = "En cours: Gestion des POIs"
            orl.orl_pois(plan_data=d)

            self.Status.Text = "En cours: Création des ROIs (peut prendre un peu de temps)"

            orl.orl_rois(plan_data=d)

            self.Status.Text = "En cours: Ajout du plan et beamset"
            orl.orl_add_plan_and_beamset(plan_data=d)

            #dose color table adjustment if selected
            if self.check2.Checked:
                self.Status.Text = "En cours: Reglage du Dose Color Table"
                orl.orl_create_isodose_lines(plan_data=d)

            #add beams or arcs
            self.Status.Text = "En cours: Ajout des faisceaux"
            orl.orl_add_beams(plan_data=d)

            #optimisation parameters and objectives
            self.Status.Text = "En cours: Reglage des paramètres d'optimisation"
            orl.orl_opt_settings(plan_data=d)

            self.Status.Text = "En cours: Ajout des objectifs d'optimisation"
            if self.check3.Checked:
                optimization_objectives.add_opt_obj_orl(plan_data=d, yeux=True)
            else:
                optimization_objectives.add_opt_obj_orl(plan_data=d)

            self.Status.Text = "En cours: Ajout des clinical goals"
            clinical_goals.cg_orl(plan_data=d)

            # Double optimization if requested by user
            if self.check1.Checked:
                self.Status.Text = "En cours: Première optimization"
                patient.TreatmentPlans[
                    d['plan_name']].PlanOptimizations[0].RunOptimization()
                self.Status.Text = "En cours: Deuxième optimization"
                patient.TreatmentPlans[
                    d['plan_name']].PlanOptimizations[0].RunOptimization()
                self.Status.Text = "En cours: Ajustement des paramètres d'optimisation"
                optim.fit_objectives_orl(
                    plan=patient.TreatmentPlans[d['plan_name']],
                    beamset=patient.TreatmentPlans[d['plan_name']].BeamSets[0])
                patient.TreatmentPlans[d['plan_name']].PlanOptimizations[
                    0].OptimizationParameters.Algorithm.MaxNumberOfIterations = 29
                self.Status.Text = "En cours: Optimisation post ajustement -30 itérations- "
                patient.TreatmentPlans[
                    d['plan_name']].PlanOptimizations[0].RunOptimization()
            self.Status.Text = "Script terminé! Cliquez sur Cancel pour sortir."
            self.Status.ForeColor = Color.Green

        def cancelClicked(self, sender, args):
            self.Close()

        def setupMachineSelectPanel(self):
            self.MachineSelectPanel = self.miniPanel(0, 450)

            self.MachineLabel = Label()
            self.MachineLabel.Text = "Appareil de traitement:"
            self.MachineLabel.Location = Point(25, 30)
            self.MachineLabel.Font = Font("Arial", 10)
            self.MachineLabel.AutoSize = True

            self.BeamModButton = RadioButton()
            self.BeamModButton.Text = "BeamMod (salles 11-12)"
            self.BeamModButton.Location = Point(40, 55)
            self.BeamModButton.Checked = False
            self.BeamModButton.AutoSize = True

            self.InfinityButton = RadioButton()
            self.InfinityButton.Text = "Infinity (salles 1-2-6)"
            self.InfinityButton.Location = Point(40, 80)
            self.InfinityButton.Checked = True
            self.InfinityButton.AutoSize = True

            self.MachineSelectPanel.Controls.Add(self.MachineLabel)
            self.MachineSelectPanel.Controls.Add(self.BeamModButton)
            self.MachineSelectPanel.Controls.Add(self.InfinityButton)

        def setupOKButtons(self):
            self.OKbuttonPanel = self.newPanel(0, 600)

            okButton = Button()
            okButton.Text = "OK"
            okButton.Location = Point(25, 50)
            self.AcceptButton = okButton
            okButton.Click += self.okClicked

            cancelButton = Button()
            cancelButton.Text = "Cancel"
            cancelButton.Location = Point(okButton.Left + okButton.Width + 10,
                                          okButton.Top)
            self.CancelButton = cancelButton
            cancelButton.Click += self.cancelClicked

            self.Status = Label()
            self.Status.Text = ""
            self.Status.Location = Point(200, 50)
            self.Status.AutoSize = True
            self.Status.Font = Font("Arial", 12, FontStyle.Bold)
            self.Status.ForeColor = Color.Black

            self.OKbuttonPanel.Controls.Add(okButton)
            self.OKbuttonPanel.Controls.Add(cancelButton)
            self.OKbuttonPanel.Controls.Add(self.Status)

            for CT in patient.Examinations:
                self.scancombo.Items.Add(CT.Name)
            try:
                self.scancombo.SelectedIndex = self.scancombo.FindStringExact(
                    "CT 1")
            except:
                self.scancombo.SelectedIndex = 0
Example #17
0
        def setupBeamset1Window(self):
            self.Beamset1Window = self.beamsetPanel(0, 60)

            vert_spacer = 30
            offset = 28

            self.beamset1Header = Label()
            self.beamset1Header.Text = "Beamset 1"
            self.beamset1Header.Location = Point(25, 25)
            self.beamset1Header.Font = Font("Arial", 11, FontStyle.Bold)
            self.beamset1Header.AutoSize = True

            self.Label1 = Label()
            self.Label1.Text = "Beamset:"
            self.Label1.Location = Point(25, vert_spacer + offset)
            self.Label1.Font = Font("Arial", 10)
            self.Label1.AutoSize = True

            self.beamset1combo = ComboBox()
            self.beamset1combo.Parent = self
            self.beamset1combo.Size = Size(120, 40)
            self.beamset1combo.Location = Point(100, vert_spacer + offset)
            self.beamset1combo.Text = "Choisissez beamset"
            self.beamset1combo.TextChanged += self.beamset1selectionChanged

            self.Label2 = Label()
            self.Label2.Text = "Site:"
            self.Label2.Location = Point(25, 2 * vert_spacer + offset)
            self.Label2.Font = Font("Arial", 10)
            self.Label2.AutoSize = True

            self.site1combo = ComboBox()
            self.site1combo.Parent = self
            self.site1combo.Size = Size(120, 40)
            self.site1combo.Location = Point(100, 2 * vert_spacer + offset)
            self.site1combo.Items.Add("Prostate")
            self.site1combo.Items.Add("Poumon")
            self.site1combo.Items.Add("Crâne")
            self.site1combo.Items.Add("Foie")
            self.site1combo.Items.Add("Vertebre")
            self.site1combo.Items.Add("ORL")
            self.site1combo.Text = "Choisissez site"
            self.site1combo.TextChanged += self.site1selectionChanged

            self.Label3 = Label()
            self.Label3.Text = "Gy en"
            self.Label3.Location = Point(70, 3 * vert_spacer + offset)
            self.Label3.Font = Font("Arial", 10)
            self.Label3.AutoSize = True

            self.Label4 = Label()
            self.Label4.Text = "fractions"
            self.Label4.Location = Point(160, 3 * vert_spacer + offset)
            self.Label4.Font = Font("Arial", 10)
            self.Label4.AutoSize = True

            self.dosebox = TextBox()
            self.dosebox.Text = "----"
            self.dosebox.Location = Point(25, 3 * vert_spacer + offset)
            self.dosebox.Width = 40

            self.fxbox = TextBox()
            self.fxbox.Text = "----"
            self.fxbox.Location = Point(115, 3 * vert_spacer + offset)
            self.fxbox.Width = 40

            self.Label5 = Label()
            self.Label5.Text = "Nom du PTV: "
            self.Label5.Location = Point(25, 4.75 * vert_spacer + offset)
            self.Label5.Font = Font("Arial", 10)
            self.Label5.AutoSize = True

            self.Label6 = Label()
            self.Label6.Text = "Contour isodose: "
            self.Label6.Location = Point(25, 5.5 * vert_spacer + offset)
            self.Label6.Font = Font("Arial", 10)
            self.Label6.AutoSize = True

            self.Label7 = Label()
            self.Label7.Text = "Nom final du beamset: "
            self.Label7.Location = Point(25, 6.25 * vert_spacer + offset)
            self.Label7.Font = Font("Arial", 10)
            self.Label7.AutoSize = True

            self.Label8 = Label()
            self.Label8.Text = "OARs pour transfert SuperBridge: "
            self.Label8.Location = Point(25, 8 * vert_spacer + offset)
            self.Label8.Font = Font("Arial", 10)
            self.Label8.AutoSize = True

            self.Beamset1Window.Controls.Add(self.beamset1Header)
            self.Beamset1Window.Controls.Add(self.Label1)
            self.Beamset1Window.Controls.Add(self.beamset1combo)
            self.Beamset1Window.Controls.Add(self.Label2)
            self.Beamset1Window.Controls.Add(self.site1combo)
            self.Beamset1Window.Controls.Add(self.Label3)
            self.Beamset1Window.Controls.Add(self.Label4)
            self.Beamset1Window.Controls.Add(self.dosebox)
            self.Beamset1Window.Controls.Add(self.fxbox)
            self.Beamset1Window.Controls.Add(self.Label5)
            self.Beamset1Window.Controls.Add(self.Label6)
            self.Beamset1Window.Controls.Add(self.Label7)
            self.Beamset1Window.Controls.Add(self.Label8)
Example #18
0
        def setupBeamset3Window(self):
            self.Beamset3Window = self.medPanel(300, 360)

            vert_spacer = 30
            offset = 28

            self.Beamset3Header = Label()
            self.Beamset3Header.Text = "Beamset 3"
            self.Beamset3Header.Location = Point(25, 25)
            self.Beamset3Header.Font = Font("Arial", 11, FontStyle.Bold)
            self.Beamset3Header.AutoSize = True

            self.Label31 = Label()
            self.Label31.Text = "Beamset:"
            self.Label31.Location = Point(25, vert_spacer + offset)
            self.Label31.Font = Font("Arial", 10)
            self.Label31.AutoSize = True

            self.beamset3combo = ComboBox()
            self.beamset3combo.Parent = self
            self.beamset3combo.Size = Size(120, 40)
            self.beamset3combo.Location = Point(100, vert_spacer + offset)
            self.beamset3combo.Text = "Choisissez beamset"
            self.beamset3combo.TextChanged += self.beamset3selectionChanged

            self.Label32 = Label()
            self.Label32.Text = "Site:"  # Site for Beamset3 is copied from Beamset1
            self.Label32.Location = Point(25, 2 * vert_spacer + offset)
            self.Label32.Font = Font("Arial", 10)
            self.Label32.AutoSize = True

            self.Label33 = Label()
            self.Label33.Text = "Gy en"
            self.Label33.Location = Point(70, 3 * vert_spacer + offset)
            self.Label33.Font = Font("Arial", 10)
            self.Label33.AutoSize = True

            self.Label34 = Label()
            self.Label34.Text = "fractions"
            self.Label34.Location = Point(160, 3 * vert_spacer + offset)
            self.Label34.Font = Font("Arial", 10)
            self.Label34.AutoSize = True

            self.dosebox3 = TextBox()
            self.dosebox3.Text = "----"
            self.dosebox3.Location = Point(25, 3 * vert_spacer + offset)
            self.dosebox3.Width = 40

            self.fxbox3 = TextBox()
            self.fxbox3.Text = "----"
            self.fxbox3.Location = Point(115, 3 * vert_spacer + offset)
            self.fxbox3.Width = 40

            self.Label35 = Label()
            self.Label35.Text = "Nom du PTV: "
            self.Label35.Location = Point(25, 4.75 * vert_spacer + offset)
            self.Label35.Font = Font("Arial", 10)
            self.Label35.AutoSize = True

            self.Label36 = Label()
            self.Label36.Text = "Contour isodose: "
            self.Label36.Location = Point(25, 5.5 * vert_spacer + offset)
            self.Label36.Font = Font("Arial", 10)
            self.Label36.AutoSize = True

            self.Label37 = Label()
            self.Label37.Text = "Nom final du beamset: "
            self.Label37.Location = Point(25, 6.25 * vert_spacer + offset)
            self.Label37.Font = Font("Arial", 10)
            self.Label37.AutoSize = True

            self.Beamset3Window.Controls.Add(self.Beamset3Header)
            self.Beamset3Window.Controls.Add(self.Label31)
            self.Beamset3Window.Controls.Add(self.beamset3combo)
            self.Beamset3Window.Controls.Add(self.Label32)
            self.Beamset3Window.Controls.Add(self.Label33)
            self.Beamset3Window.Controls.Add(self.Label34)
            self.Beamset3Window.Controls.Add(self.dosebox3)
            self.Beamset3Window.Controls.Add(self.fxbox3)
            self.Beamset3Window.Controls.Add(self.Label35)
            self.Beamset3Window.Controls.Add(self.Label36)
            self.Beamset3Window.Controls.Add(self.Label37)
Example #19
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)
    def __init__(self):
        self.file_path = DEFAULT_PATH
        self.Text = 'Waypoint File Tool'
        self.Location = Point(0, 0)
        self.TopMost = ALWAYS_ON_TOP
        screen_size = Screen.GetWorkingArea(self)
        num_buttons = 3
        btn_width = 150
        margin = 5
        start_x, start_y = 12, 10
        self.Height = screen_size.Height
        self.Width = btn_width * num_buttons + margin * (num_buttons + 7)
        self.BackColor = CustomColor.MPDarkGray
        self.ForeColor = CustomColor.White
        """ OpenFileDialog does not appear to work in Mission Planner scripts...
                so, we create a rudimentary file picker with a textbox and listbox """
        self.txt_path = TextBox()
        self.txt_path.Width = self.Width - (margin * 8)
        self.txt_path.BorderStyle = BorderStyle.FixedSingle
        self.txt_path.BackColor = CustomColor.MPLightGray
        self.txt_path.ForeColor = CustomColor.White
        self.txt_path.Text = self.file_path
        self.txt_path.LostFocus += self.refresh_filenames

        self.lst_files = ListBox()
        self.lst_files.Width = self.txt_path.Width
        self.lst_files.Height = self.Height / 5
        self.lst_files.BorderStyle = BorderStyle.FixedSingle
        self.lst_files.BackColor = CustomColor.MPLightGray
        self.lst_files.ForeColor = CustomColor.White
        self.lst_files.SelectedIndexChanged += self.file_selection_changed

        self.btn_output_wp = Button()
        self.btn_output_wp.Width = 150
        self.btn_output_wp.FlatStyle = FlatStyle.Flat
        self.btn_output_wp.FlatAppearance.BorderSize = 1
        self.btn_output_wp.FlatAppearance.BorderColor = CustomColor.MPLightGray
        self.btn_output_wp.BackColor = CustomColor.MPGreen
        self.btn_output_wp.ForeColor = CustomColor.Black
        self.btn_output_wp.Text = 'Output as WP'
        self.btn_output_wp.Click += self.convert_file

        self.btn_output_poly = Button()
        self.btn_output_poly.Width = 150
        self.btn_output_poly.FlatStyle = FlatStyle.Flat
        self.btn_output_poly.FlatAppearance.BorderSize = 1
        self.btn_output_poly.FlatAppearance.BorderColor = CustomColor.MPLightGray
        self.btn_output_poly.BackColor = CustomColor.MPGreen
        self.btn_output_poly.ForeColor = CustomColor.Black
        self.btn_output_poly.Text = 'Output as POLY'
        self.btn_output_poly.Click += self.convert_file

        self.btn_refresh_files = Button()
        self.btn_refresh_files.Width = 150
        self.btn_refresh_files.FlatStyle = FlatStyle.Flat
        self.btn_refresh_files.FlatAppearance.BorderSize = 1
        self.btn_refresh_files.FlatAppearance.BorderColor = CustomColor.MPLightGray
        self.btn_refresh_files.BackColor = CustomColor.MPGreen
        self.btn_refresh_files.ForeColor = CustomColor.Black
        self.btn_refresh_files.Text = 'Refresh Files'
        self.btn_refresh_files.Click += self.refresh_filenames
        self.AcceptButton = self.btn_refresh_files

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

        self.chk_reverse_perimeter = CheckBox()
        self.chk_reverse_perimeter.FlatAppearance.BorderSize = 1
        self.chk_reverse_perimeter.FlatAppearance.BorderColor = CustomColor.MPLightGray
        self.chk_reverse_perimeter.Text = 'Reverse Perimeter - Enter desired number of passes:'
        self.chk_reverse_perimeter.AutoSize = True
        self.chk_reverse_perimeter.CheckedChanged += self.set_txt_num_perimeter_passes_state
        self.chk_reverse_perimeter.Checked = True

        self.lbl_default_altitude = Label()
        self.lbl_default_altitude.Text = 'Waypoint Altitude (if unspecified):'
        self.lbl_default_altitude.AutoSize = True

        self.txt_default_altitude = TextBox()
        self.txt_default_altitude.Width = 50
        self.txt_default_altitude.BorderStyle = BorderStyle.FixedSingle
        self.txt_default_altitude.BackColor = CustomColor.MPLightGray
        self.txt_default_altitude.ForeColor = CustomColor.White
        self.txt_default_altitude.MaxLength = 5
        self.txt_default_altitude.TextAlign = HorizontalAlignment.Center
        self.txt_default_altitude.Text = str(
            round(DEFAULT_ALTITUDE * 3.28084, 2))[:5]
        self.txt_default_altitude.KeyPress += self.limit_to_decimal_digits

        self.cbo_default_altitude = ComboBox()
        self.cbo_default_altitude.Width = 60
        self.cbo_default_altitude.DropDownStyle = ComboBoxStyle.DropDownList
        self.cbo_default_altitude.FlatStyle = FlatStyle.Flat
        self.cbo_default_altitude.BackColor = CustomColor.MPLightGray
        self.cbo_default_altitude.ForeColor = CustomColor.White
        self.cbo_default_altitude.DataSource = ['Feet', 'Meters']
        self.cbo_default_altitude.SelectionChangeCommitted += self.convert_altitude_units

        self.lbl_status = Label()
        self.lbl_status.Text = 'Choose a file...'
        self.lbl_status.BackColor = CustomColor.MPMediumGray
        self.lbl_status.Width = self.txt_path.Width
        self.lbl_status.Height = self.txt_path.Height - 5

        # pseudo-responsive form layout
        x, y = start_x, start_y
        x, y = self.add_control_vertical(self.txt_path, x, y, margin)
        x, y = self.add_control_vertical(self.lst_files, x, y, margin)
        x, y = self.add_control_horizontal(self.btn_output_wp, x, y, margin)
        x, y = self.add_control_horizontal(self.btn_output_poly, x, y, margin)
        x, y = self.add_control_vertical(self.btn_refresh_files, x, y,
                                         margin + 10)
        x, y = self.add_control_horizontal(self.chk_reverse_perimeter, start_x,
                                           y, margin)
        x, y = self.add_control_vertical(self.spn_num_perimeter_passes, x - 5,
                                         y, margin + 10)
        x, y = self.add_control_horizontal(self.lbl_default_altitude, start_x,
                                           y + 3, margin)
        x, y = self.add_control_horizontal(self.txt_default_altitude, x, y - 3,
                                           margin + 3)
        x, y = self.add_control_vertical(self.cbo_default_altitude, x, y,
                                         margin)
        self.Height = y + 100
        self.add_control_vertical(self.lbl_status, start_x, self.Height - 60,
                                  margin)

        self.set_txt_num_perimeter_passes_state(None, None)
        self.refresh_filenames(None, None)
Example #21
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
Example #22
0
class HFSSAssignPort(Form):
    def __init__(self):
        self.Text = "HFSS_GUI_Scripts_#2"

        screenSize = Screen.GetWorkingArea(self)
        # self.Width = 350
        # self.Height = 300
        self.Width = 350
        self.Height = 300
        self.FormBorderStyle = FormBorderStyle.Fixed3D
        self.MaximizeBox = False

        self.authorName = Label()
        self.authorName.Text = "by Phower"
        self.authorName.Height = 25
        self.authorName.AutoSize = True
        self.authorName.Location = Point(265, 245)
        # self.authorName.Anchor = AnchorStyles.Left | AnchorStyles.Bottom

        self.setupPanel1()
        self.setupPanel2()

        self.Controls.Add(self.panel1)
        self.Controls.Add(self.panel2)
        self.Controls.Add(self.authorName)

    def setupPanel1(self):
        self.panel1 = Panel()
        self.panel1.Width = self.Width
        self.panel1.Height = 120
        self.panel1.Location = Point(0, 0)
        self.panel1.BorderStyle = BorderStyle.FixedSingle

        self.title1 = Label()
        self.title1.Text = "ReAssign Terminal"
        self.title1.Location = Point(25, 22)
        self.title1.Height = 25
        self.title1.AutoSize = True

        self.label2 = Label()
        self.label2.Text = "Ground Metal Name: "
        self.label2.Location = Point(25, 50)
        self.label2.Height = 25
        self.label2.Width = 150

        self.button1 = Button()
        self.button1.Text = 'Assign'
        self.button1.Location = Point(25, 75)
        self.button1.Width = 100
        self.button1.Click += self.update

        self.button2 = Button()
        self.button2.Text = 'Reset'
        self.button2.Location = Point(180, 75)
        self.button2.Width = 100
        self.button2.Click += self.reset

        self.list1 = ComboBox()
        self.list1.Text = '——Select'
        self.list1.Location = Point(180, 47)
        self.list1.Width = 100
        self.list1.Height = 35
        self.DropDownHeight = 50
        self.list1.Click += self.listUpdate

        self.AcceptButton = self.button1
        self.CancelButton = self.button2

        self.panel1.Controls.Add(self.label2)
        self.panel1.Controls.Add(self.title1)
        self.panel1.Controls.Add(self.button1)
        self.panel1.Controls.Add(self.button2)
        self.panel1.Controls.Add(self.list1)

    def setupPanel2(self):
        self.panel2 = Panel()
        # self.panel2.Text = "Panel"
        self.panel2.Width = self.Width
        self.panel2.Height = 120
        self.panel2.Location = Point(0, 120)
        self.panel2.BorderStyle = BorderStyle.FixedSingle

        self.p2title1 = Label()
        self.p2title1.Text = "Create Lumped Port"
        self.p2title1.Location = Point(25, 22)
        self.p2title1.Height = 25
        self.p2title1.AutoSize = True

        self.p2label1 = Label()
        self.p2label1.Text = "Ground Metal Name: "
        self.p2label1.Location = Point(25, 50)
        self.p2label1.Height = 25
        self.p2label1.Width = 150

        self.p2button1 = Button()
        self.p2button1.Text = 'Create'
        self.p2button1.Location = Point(25, 75)
        self.p2button1.Width = 100
        self.p2button1.Click += self.p2update

        self.p2button2 = Button()
        self.p2button2.Text = 'Reset'
        self.p2button2.Location = Point(180, 75)
        self.p2button2.Width = 100
        self.p2button2.Click += self.p2reset

        self.p2list1 = ComboBox()
        self.p2list1.Text = '——Select'
        self.p2list1.Location = Point(180, 47)
        self.p2list1.Width = 100
        self.p2list1.Height = 35
        self.DropDownHeight = 50
        self.p2list1.Click += self.p2listUpdate

        self.AcceptButton = self.p2button1
        self.CancelButton = self.p2button2

        self.panel2.Controls.Add(self.p2title1)
        self.panel2.Controls.Add(self.p2label1)
        self.panel2.Controls.Add(self.p2button1)
        self.panel2.Controls.Add(self.p2button2)
        self.panel2.Controls.Add(self.p2list1)

    def update(self, sender, event):
        temp = oModule.GetPortExcitationCounts()
        tempNum = len(temp)
        tempRecord = []
        for x in range(1, tempNum, 2):
            if temp[x] == '0':
                tempRecord.append(temp[x - 1])
        # MessageBox.Show(str(tempRecord))
        temp2 = self.list1.SelectedItem
        if tempRecord and (temp2 != None):
            AssignPort(tempRecord, str(temp2))
        elif temp2 == None:
            MessageBox.Show("请选择参考金属")
        elif len(tempRecord) == 0:
            MessageBox.Show("全部Port已完成")
        else:
            MessageBox.Show("错误参数!!")

    def reset(self, sender, event):
        global refresh_count
        if (self.list1.SelectedItem != None):
            self.list1.Items.Clear()
            self.list1.Text = '——Select'
            refresh_count = 0
            MessageBox.Show("已重置!!")
        else:
            MessageBox.Show("已重置!!")

    def listUpdate(self, sender, event):
        global refresh_count
        if (refresh_count == 0):
            refresh_count = 1
            self.list1.BeginUpdate()
            # self.list1.Items.AddRange(tuple(oEditor.GetObjectsByMaterial("m10_tsmcN40", "m2_tsmcN40")))
            # self.list1.Items.AddRange(tuple(oEditor.GetObjectsInGroup("Solids")))
            self.list1.Items.AddRange(tuple(
                oEditor.GetMatchedObjectName("M*")))
            self.list1.EndUpdate()

    def p2listUpdate(self, sender, event):
        global refresh_count2
        if (refresh_count2 == 0):
            refresh_count2 = 1
            self.p2list1.BeginUpdate()
            self.p2list1.Items.AddRange(
                tuple(oEditor.GetMatchedObjectName("M*")))
            self.p2list1.EndUpdate()

    def p2update(self, sender, event):
        temp = self.p2list1.SelectedItem
        unPort = oEditor.GetObjectsInGroup("Unassigned")
        unPortID = []
        for x in range(0, len(unPort)):
            unPortID.append(oEditor.GetFaceIDs(unPort[x])[0])
        if unPortID and (temp != None):
            CreatePort(unPortID, unPort, temp)
        elif temp == None:
            MessageBox.Show("请选择参考金属")
        elif len(unPortID) == 0:
            MessageBox.Show("全部Port已完成")
        else:
            MessageBox.Show("错误参数!!")
        # MessageBox.Show(str(unPortID))

    def p2reset(self, sender, event):
        global refresh_count2
        if (self.p2list1.SelectedItem != None):
            self.p2list1.Items.Clear()
            self.p2list1.Text = '——Select'
            refresh_count2 = 0
            MessageBox.Show("已重置!!")
        else:
            MessageBox.Show("已重置!!")
Example #23
0
  def __init__(self, curveId):
    
    label_width = 30
    offset = 30
    index = 0
    
    # header
    self.Text = "Annotate Curve"
    
    #label
    index += 1

    crvlabel = Label(Text="Curve ID = "+str(curveId), AutoSize=True)
    self.Controls.Add(crvlabel)
    width = crvlabel.Right
    pt = Point(crvlabel.Left,crvlabel.Bottom + offset)
    
    #textInput
    labelstart = Label(Text="Text at start", AutoSize=True)
    labelstart.Location = Point(label_width, offset* index)
    self.Controls.Add(labelstart)
    pt.X = labelstart.Right + offset
    inputstart = TextBox(Text="Start")
    inputstart.Location = pt
    self.Controls.Add(inputstart)
    if( inputstart.Right > width ):
      width = inputstart.Right
    self.m_inputstart = inputstart

    index += 1
    cb = CheckBox( AutoSize=True)
    cb.Parent = self
    cb.Location = Point(label_width, offset* index)
    cb.Text = "Show Title"
    cb.Checked = True

    
    
    index += 1
    cbb = ComboBox(Text="select tool", Location=Point(label_width, offset * index), Parent=self)
    cbb.Items.AddRange(("Inner contour",
            "Outer contour",
            "Pocket",
            "Engrave",
            "Clamex horizontal"))
    
    self.cbb_tool = cbb

    index += 1
    cbb = ComboBox(Text="Outer contour", Location=Point(label_width, offset * index), Parent=self)
    cbb.Items.AddRange(("Inner contour",
            "Outer contour",
            "Pocket",
            "Engrave",
            "Clamex horizontal"))    
    
    self.cbb_operation = cbb
            
    index += 1
    sb = NumericUpDown( AutoSize=True, Location=Point(label_width, offset * index), Parent=self , DecimalPlaces = 2) 
    sb.Parent = self
    sb.Location = Point(label_width, offset* index)
    sb.DecimalPlaces  = 2
    sb.Text = "Show Title"
  
            
      

    
    index += 1
    pt.X  = labelstart.Left
    pt.Y  = labelstart.Bottom + offset*index
    buttonApply = Button(Text="Apply", DialogResult=DialogResult.OK)
    buttonApply.Location = pt
    self.Controls.Add(buttonApply)
    pt.X = buttonApply.Right + offset
    buttonCancel = Button(Text="Cancel", DialogResult=DialogResult.Cancel)
    buttonCancel.Location = pt
    self.Controls.Add(buttonCancel)
    if( buttonCancel.Right > width ):
      width = buttonCancel.Right
    self.ClientSize = Size(width, buttonCancel.Bottom)
    self.AcceptButton = buttonApply
    self.CancelButton = buttonCancel
Example #24
0
        def __init__(self, dropDownDictList, dropDownHeadings, defaultValues=[], sort=True):

            topOffset = 20
            spacing = 45

            # Create the Form
            self.Name = "ListBox"
            self.Text = "pyWeWork"
            self.FormBorderStyle = FormBorderStyle.Sizable
            self.Icon = icon
            self.CenterToScreen()
            self.values = []
            self.dropDownDictList = dropDownDictList
            self.dropDownHeadings = dropDownHeadings
            self.defaultValues = defaultValues
            self.comboBoxes = []
            self.labels = []
            self.Size = Size(500, spacing*len(self.dropDownHeadings) + (topOffset + 75))

            titleFont =  Font("Arial",10, FontStyle.Bold)
            menuFont = Font("Arial",8, FontStyle.Bold)

            self.label = Label()
            self.label.Text = "SELECT PARAMETERS"
            self.label.Font = titleFont
            self.label.Location = Point(10, 10)
            self.label.AutoSize = True
            
            for index in range(len(self.dropDownDictList)):
                dropDownDict = self.dropDownDictList[index]
                if sort:
                    dictKeys = sorted(dropDownDict.keys())
                    dictValues = sorted(dropDownDict.values())
                else:
                    dictKeys = dropDownDict.keys()
                    dictValues = dropDownDict.values()
                
                self.comboBoxes.append(ComboBox())
                for item in dictKeys:
                    self.comboBoxes[index].Items.Add(item)
                self.comboBoxes[index].Location = Point(15, (spacing*index) + topOffset)
                self.comboBoxes[index].Width = 250
                if self.defaultValues:
                    selectedIndex = 0
                    for key in dictKeys:
                        defaultVal = self.defaultValues[index]
                        if dropDownDict[key] == defaultVal:
                            selectedIndex = dictKeys.index(key)
                    self.comboBoxes[index].SelectedIndex = selectedIndex
                self.labels.append(Label())
                self.labels[index].Text = self.dropDownHeadings[index]
                self.labels[index].Font = menuFont
                self.labels[index].Width = 100
                self.labels[index].AutoSize = True
                self.labels[index].Location = Point(280, (spacing*index) + topOffset + 2)
                self.Controls.Add(self.labels[index])
                self.Controls.Add(self.labels[index])
                self.Controls.Add(self.comboBoxes[index])

            self.button = Button()
            self.button.Text = "GO"
            self.button.Size = Size(0, 40)
            self.button.Dock = DockStyle.Bottom
            
            # Register event
            self.button.Click += self.ButtonClicked


            self.Controls.Add(self.button)
        def setupMainWindow(self):
            self.MainWindow = self.Panel(0, 60)
            
            vert_spacer = 30
            offset = 50   
            
            self.toplabel = Label()
            self.toplabel.Text = "PTV                      Dose (Gy)"
            self.toplabel.Font = Font("Arial", 10, FontStyle.Bold)
            self.toplabel.Location = Point(60, 20)
            self.toplabel.AutoSize = True  
                   
            self.PTV1combo = ComboBox()
            self.PTV1combo.Parent = self
            self.PTV1combo.Size = Size(120,40)
            self.PTV1combo.Location = Point(25, offset)
            self.PTV1combo.Text = "Choisissez ROI" 
     
            self.dose1_value = TextBox()
            self.dose1_value.Text = ""
            self.dose1_value.Location = Point(180, offset)
            self.dose1_value.Width = 50              

            self.PTV2combo = ComboBox()
            self.PTV2combo.Parent = self
            self.PTV2combo.Size = Size(120,40)
            self.PTV2combo.Location = Point(25, offset + vert_spacer)
            self.PTV2combo.Text = "Choisissez ROI" 

            self.dose2_value = TextBox()
            self.dose2_value.Text = ""
            self.dose2_value.Location = Point(180, offset + vert_spacer)
            self.dose2_value.Width = 50                                

            self.PTV3combo = ComboBox()
            self.PTV3combo.Parent = self
            self.PTV3combo.Size = Size(120,40)
            self.PTV3combo.Location = Point(25, offset + 2*vert_spacer)
            self.PTV3combo.Text = "Choisissez ROI" 
                      
            self.dose3_value = TextBox()
            self.dose3_value.Text = ""
            self.dose3_value.Location = Point(180, offset + 2*vert_spacer)
            self.dose3_value.Width = 50                   
         
         
            self.fxlabel = Label()
            self.fxlabel.Text = "Nb de fx"
            self.fxlabel.Location = Point(25, offset + 3.5*vert_spacer)
            self.fxlabel.Font = Font("Arial", 10, FontStyle.Bold)
            self.fxlabel.AutoSize = True              
            
            self.fxbox = TextBox()
            self.fxbox.Parent = self
            self.fxbox.Size = Size(50,40)
            self.fxbox.Location = Point(150, offset + 3.5*vert_spacer)
            self.fxbox.Text = "1"                 
            
            self.techlabel = Label()
            self.techlabel.Text = "Technique"
            self.techlabel.Location = Point(25, offset + 4.5*vert_spacer)
            self.techlabel.Font = Font("Arial", 10, FontStyle.Bold)
            self.techlabel.AutoSize = True              
            
            self.techcombo = ComboBox()
            self.techcombo.Parent = self
            self.techcombo.Size = Size(90,40)
            self.techcombo.Location = Point(150, offset + 4.5*vert_spacer)
            self.techcombo.Text = "VMAT" 
            self.techcombo.Items.Add('VMAT')
            self.techcombo.Items.Add('IMRT')
            self.techcombo.Items.Add('3DC')        
            
            self.sitelabel = Label()
            self.sitelabel.Text = "Nom du site"
            self.sitelabel.Location = Point(25, offset + 5.5*vert_spacer)
            self.sitelabel.Font = Font("Arial", 10, FontStyle.Bold)
            self.sitelabel.AutoSize = True              
            
            self.sitebox = TextBox()
            self.sitebox.Parent = self
            self.sitebox.Size = Size(50,40)
            self.sitebox.Location = Point(150, offset + 5.5*vert_spacer)
            self.sitebox.Text = "A1"    
            
            
            self.isolabel = Label()
            self.isolabel.Text = "Isocentre"
            self.isolabel.Location = Point(25, offset + 6.5*vert_spacer)
            self.isolabel.Font = Font("Arial", 10, FontStyle.Bold)
            self.isolabel.AutoSize = True              
            
            self.isocombo = ComboBox()
            self.isocombo.Parent = self
            self.isocombo.Size = Size(90,40)
            self.isocombo.Location = Point(150, offset + 6.5*vert_spacer)
            for poi in patient.PatientModel.PointsOfInterest:
                self.isocombo.Items.Add(poi.Name)
                if poi.Name == 'ISO':
                    self.isocombo.Text = 'ISO'
                elif self.isocombo.Text != 'ISO' and poi.Name == 'REF SCAN':
                    self.isocombo.Text = 'REF SCAN'
            
            
            self.scanlabel = Label()
            self.scanlabel.Text = "CT de planif"
            self.scanlabel.Location = Point(25, offset + 7.5*vert_spacer)
            self.scanlabel.Font = Font("Arial", 10, FontStyle.Bold)
            self.scanlabel.AutoSize = True              
            
            self.scancombo = ComboBox()
            self.scancombo.Parent = self
            self.scancombo.Size = Size(90,40)
            self.scancombo.Location = Point(150, offset + 7.5*vert_spacer)
            for ct in patient.Examinations:
                self.scancombo.Items.Add(ct.Name)         
                if ct.Name == 'CT 1':
                    self.scancombo.Text = 'CT 1'
            
            
            self.machinelabel = Label()
            self.machinelabel.Text = "Appareil"
            self.machinelabel.Location = Point(25, offset + 8.5*vert_spacer)
            self.machinelabel.Font = Font("Arial", 10, FontStyle.Bold)
            self.machinelabel.AutoSize = True              
            
            self.machinecombo = ComboBox()
            self.machinecombo.Parent = self
            self.machinecombo.Size = Size(90,40)
            self.machinecombo.Location = Point(150, offset + 8.5*vert_spacer)
            self.machinecombo.Text = "BeamMod"                  
            self.machinecombo.Items.Add('BeamMod')
            self.machinecombo.Items.Add('Infinity')
            

            self.isodoselabel = Label()
            self.isodoselabel.Text = "Dose table"
            self.isodoselabel.Location = Point(25, offset + 9.5*vert_spacer)
            self.isodoselabel.Font = Font("Arial", 10, FontStyle.Bold)
            self.isodoselabel.AutoSize = True              
            
            self.isodosecombo = ComboBox()
            self.isodosecombo.Parent = self
            self.isodosecombo.Size = Size(90,40)
            self.isodosecombo.Location = Point(150, offset + 9.5*vert_spacer)
            self.isodosecombo.Text = "Créer"                  
            self.isodosecombo.Items.Add('Créer')            
            self.isodosecombo.Items.Add('Ne pas créer')            


            self.couchlabel = Label()
            self.couchlabel.Text = "Couch table"
            self.couchlabel.Location = Point(25, offset + 10.5*vert_spacer)
            self.couchlabel.Font = Font("Arial", 10, FontStyle.Bold)
            self.couchlabel.AutoSize = True              
            
            self.couchcombo = ComboBox()
            self.couchcombo.Parent = self
            self.couchcombo.Size = Size(90,40)
            self.couchcombo.Location = Point(150, offset + 10.5*vert_spacer)
            self.couchcombo.Text = "Ne pas ajouter"                  
            self.couchcombo.Items.Add('Ne pas ajouter')            
            #self.couchcombo.Items.Add('Ajouter')                  

            
            self.message = Label()
            self.message.Text = "Sélectionnez le(s) ROI(s) à traiter (chaque\ncontour distinct devrait être indiqué\nséparément). Seulement les ROIs avec\nPTV dans leurs noms sont disponibles.\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nLes plans IMRT/3DC avec plusieurs PTVs\ndistincts auront une optimisation automatique\ndu collimateur. SVP ne touchez pas à\nl'ordinateur pendant cette optimisation\n(4 à 5 minutes environ)"
            self.message.Location = Point(300, offset)
            self.message.Font = Font("Arial", 11, FontStyle.Italic)
            self.message.AutoSize = True                
            
            self.status = Label()
            self.status.Text = ""
            self.status.Location = Point(25, 760)
            self.status.Font = Font("Arial", 11, FontStyle.Bold)
            self.status.AutoSize = True    
            

            self.OARlabel = Label()
            self.OARlabel.Text = "Max doses custom (Gy)"
            self.OARlabel.Location = Point(25, offset + 13*vert_spacer)
            self.OARlabel.Font = Font("Arial", 10, FontStyle.Bold)
            self.OARlabel.AutoSize = True              
            
            self.OAR1combo = ComboBox()
            self.OAR1combo.Parent = self
            self.OAR1combo.Size = Size(120,40)
            self.OAR1combo.Location = Point(25, offset + 14*vert_spacer)
            self.OAR1combo.Text = "Choisissez OAR"     

            self.OAR1_value = TextBox()
            self.OAR1_value.Text = ""
            self.OAR1_value.Location = Point(160, offset + 14*vert_spacer)
            self.OAR1_value.Width = 50                  
            
            self.OAR2combo = ComboBox()
            self.OAR2combo.Parent = self
            self.OAR2combo.Size = Size(120,40)
            self.OAR2combo.Location = Point(25, offset + 15*vert_spacer)
            self.OAR2combo.Text = "Choisissez OAR"     
            
            self.OAR2_value = TextBox()
            self.OAR2_value.Text = ""
            self.OAR2_value.Location = Point(160, offset + 15*vert_spacer)
            self.OAR2_value.Width = 50                
            
            self.OAR3combo = ComboBox()
            self.OAR3combo.Parent = self
            self.OAR3combo.Size = Size(120,40)
            self.OAR3combo.Location = Point(25, offset + 16*vert_spacer)
            self.OAR3combo.Text = "Choisissez OAR"                 
            
            self.OAR3_value = TextBox()
            self.OAR3_value.Text = ""
            self.OAR3_value.Location = Point(160, offset + 16*vert_spacer)
            self.OAR3_value.Width = 50    

            
            evalButton = Button()
            evalButton.Text = "Évaluer les PTVs"
            evalButton.Location = Point(25, offset + 18 * vert_spacer)
            evalButton.Width = 200
            evalButton.Click += self.evalClicked                           
            
            addplanButton = Button()
            addplanButton.Text = "Ajouter plan"
            addplanButton.Location = Point(25, offset + 19 * vert_spacer)
            addplanButton.Width = 200
            addplanButton.Click += self.addplanClicked   


            self.stepcombo = ComboBox()
            self.stepcombo.Parent = self
            self.stepcombo.Size = Size(250,40)
            self.stepcombo.Location = Point(25, offset + 20 * vert_spacer)
            self.stepcombo.Text = "Rouler le script au complet"                  
            self.stepcombo.Items.Add('Rouler le script au complet')            
            self.stepcombo.Items.Add('Multi-PTV: Arrêtez avant optimization collimateur')            
            self.stepcombo.Items.Add('Multi-PTV: Reprendre après optimization collimateur')                   
            
            
            eraseROIButton = Button()
            eraseROIButton.Text = "Effacer les ROIs de prédiction"
            eraseROIButton.Location = Point(25, offset + 21.5 * vert_spacer)
            eraseROIButton.Width = 200
            eraseROIButton.Click += self.eraseROIClicked   
            
            
            
            self.MainWindow.Controls.Add(self.toplabel)
            
            self.MainWindow.Controls.Add(self.PTV1combo)
            self.MainWindow.Controls.Add(self.dose1_value)
            self.MainWindow.Controls.Add(self.PTV2combo)
            self.MainWindow.Controls.Add(self.dose2_value)
            self.MainWindow.Controls.Add(self.PTV3combo)
            self.MainWindow.Controls.Add(self.dose3_value)          

            self.MainWindow.Controls.Add(self.fxlabel)
            self.MainWindow.Controls.Add(self.fxbox)   
            
            self.MainWindow.Controls.Add(self.techlabel)          
            self.MainWindow.Controls.Add(self.techcombo)          
         
            self.MainWindow.Controls.Add(self.sitelabel)
            self.MainWindow.Controls.Add(self.sitebox)            

            self.MainWindow.Controls.Add(self.isolabel)
            self.MainWindow.Controls.Add(self.isocombo) 
            
            self.MainWindow.Controls.Add(self.scanlabel)          
            self.MainWindow.Controls.Add(self.scancombo)    
            
            self.MainWindow.Controls.Add(self.machinelabel)          
            self.MainWindow.Controls.Add(self.machinecombo)          

            self.MainWindow.Controls.Add(self.isodoselabel)          
            self.MainWindow.Controls.Add(self.isodosecombo)     

            self.MainWindow.Controls.Add(self.couchlabel)          
            self.MainWindow.Controls.Add(self.couchcombo)             
            
            self.MainWindow.Controls.Add(self.OARlabel)
            self.MainWindow.Controls.Add(self.OAR1combo)
            self.MainWindow.Controls.Add(self.OAR1_value)
            self.MainWindow.Controls.Add(self.OAR2combo)
            self.MainWindow.Controls.Add(self.OAR2_value)
            self.MainWindow.Controls.Add(self.OAR3combo)
            self.MainWindow.Controls.Add(self.OAR3_value)
            
            self.MainWindow.Controls.Add(self.message)            
            self.MainWindow.Controls.Add(self.status)     

            self.MainWindow.Controls.Add(evalButton)
            self.MainWindow.Controls.Add(addplanButton)            
            
            self.MainWindow.Controls.Add(self.stepcombo) 
            
            self.MainWindow.Controls.Add(eraseROIButton) 

            
            #Label empty contours
            exam_list = []
            for CT in patient.Examinations:
                exam_list.append(CT.Name)
                
            for contour in patient.PatientModel.RegionsOfInterest:
                VolCT1 = roi.get_roi_volume(contour.Name, exam=patient.Examinations["CT 1"])
                if "CT 2" in exam_list:
                    VolCT2 = roi.get_roi_volume(contour.Name, exam=patient.Examinations["CT 2"])
                else:
                    VolCT2 = 0

                if VolCT1 == 0 and VolCT2 == 0:
                    contour.Name = ("vide_" + contour.Name)               
Example #26
0
    def __init__(self, title, items):

        # icon
        self.Icon = _Icon(r"%s\extra\icon.ico" % ipath)
        self.Size = _Size(360, 430)
        self.Text = "Quasar"
        self.class2Result = []

        self.title = title
        self.items = items
        # fonts
        self.gsmt_11r = _Font("Georgia", 10)
        self.gsmt_10r = _Font("Georgia", 9)

        # combo box
        self.cbox = ComboBox()
        self.cbox.Font = self.gsmt_11r
        self.cbox.Location = _Point(30, 10)
        self.cbox.Size = _Size(280, 28)
        self.cbox.Items.AddRange(tuple(title))
        self.cbox.SelectedIndex = 0
        self.Controls.Add(self.cbox)

        # checklist box
        self.lstbox = CheckedListBox()
        self.lstbox.Items.AddRange(tuple(self.items[self.cbox.SelectedIndex]))
        self.lstbox.Font = self.gsmt_10r
        # padding
        self.lstbox.Padding = Padding(30)
        # select one click
        self.lstbox.CheckOnClick = True

        self.FormBorderStyle = FormBorderStyle.FixedDialog
        self.MaximizeBox = False
        self.ManimizeBox = False
        self.lstbox.Location = _Point(30, 45)
        self.lstbox.Size = _Size(280, 300)

        # auto horizontal scrollbar
        self.lstbox.HorizontalScrollbar = True
        self.Controls.Add(self.lstbox)

        # select all btn
        self.btn_all = Button()
        self.btn_all.Text = "Select All"
        self.btn_all.Font = self.gsmt_10r
        self.btn_all.Size = _Size(95, 25)
        self.btn_all.Location = _Point(30, 340)
        self.Controls.Add(self.btn_all)

        # select none btn
        self.btn_none = Button()
        self.btn_none.Text = "Select None"
        self.btn_none.Font = self.gsmt_10r
        self.btn_none.Size = _Size(95, 25)
        self.btn_none.Location = _Point(215, 340)
        self.Controls.Add(self.btn_none)

        # ok btn
        self.btn = Button()
        self.btn.Text = "OK"
        self.btn.Font = self.gsmt_10r
        self.btn.Size = _Size(80, 25)
        self.btn.Location = _Point(130, 340)
        self.Controls.Add(self.btn)

        # events
        self.btn_all.Click += self.click_all
        self.btn_none.Click += self.click_none
        self.btn.Click += self.click_ok
        self.cbox.SelectedValueChanged += self.on_class_change

        # pop up from center
        self.CenterToScreen()
    def __init__(self):  #the __init__ method inside a class is its constructor

        self.Text = "AU London"  #text that appears in the GUI titlebar
        self.Icon = Icon.FromHandle(
            icon.GetHicon()
        )  #takes a bitmap image and converts to a file that can be used as a Icon for the titlebar
        self.BackColor = Color.FromArgb(255, 255, 255)

        self.WindowState = FormWindowState.Normal  # set maximised minimised or normal size GUI
        self.CenterToScreen()  # centres GUI to the middle of your screen
        self.BringToFront()  #brings the GUI to the front of all opens windows.
        self.Topmost = True  # true to display the GUI infront of any other active forms

        screenSize = Screen.GetWorkingArea(
            self
        )  #get the size of the computers main screen, as the form will scale differently to different sized screens
        self.Width = screenSize.Width / 4  #set the size of the form based on the size of the users screen. this helps to ensure consistant look across different res screens.
        self.Height = screenSize.Height / 4
        uiWidth = self.DisplayRectangle.Width  #get the size of the form to use to scale form elements
        uiHeight = self.DisplayRectangle.Height

        #self.FormBorderStyle = FormBorderStyle.FixedDialog      # fixed dialog stops the user from adjusting the form size. Recomended disabling this when testing to see if elements are in the wrong place.

        self.userOutput = userOutputDefaultStr  #create a container to store the output from the form
        self.runNextOutput = False  #set these default values

        #############-------------\-------------#############
        spacing = 10  #spacing size for GUI elements to form a consistent border

        # creates the text box for a info message
        userMessage = Label()  #label displays texts
        font = Font("Helvetica ", 10)
        userMessage.Text = message
        userMessage.Font = font
        userMessage.Location = Point(
            spacing, spacing
        )  #all location require a point object from system.Drawing to set the location.
        userMessage.Size = Size(
            uiWidth - (spacing * 2), (uiHeight / 4)
        )  #size the control with the width of the GUI to ensure it scales with different screen
        self.Controls.Add(userMessage)  #this adds control element to the GUI

        #############-------------\-------------#############
        #logo file
        logo = PictureBox()
        logo.Image = logoFile
        ratio = float(logo.Height) / float(
            logo.Width
        )  #needs to be a float as int will round to the nearest whole number
        logo.Size = Size(
            uiWidth / 4, (uiHeight / 4) * ratio
        )  #scale the image by the ratio between the images height & width
        logo.Location = Point(spacing, (uiHeight - logo.Height) - spacing)
        logo.SizeMode = PictureBoxSizeMode.Zoom  # zooms the image to fit the extent
        logo.Anchor = (
            AnchorStyles.Bottom | AnchorStyles.Left
        )  #anchor styles lock elements to a given corner of the GUI if you allow users change size
        self.Controls.Add(logo)
        #logo.BorderStyle = BorderStyle.Fixed3D    #gives a border to the panel to test its location

        #############-------------\-------------#############

        #combox drop down
        cBox = ComboBox()  #dropdown control form
        cBox.Location = Point(spacing, uiHeight / 3)
        cBox.Width = uiWidth - (spacing * 2)
        cBox.Items.AddRange(
            listInput
        )  # Adds an array of items to the list of items for a ComboBox.
        cBox.DropDownStyle = ComboBoxStyle.DropDownList  #setting to dropdown list prevents users from being able to add aditional text values
        cBox.SelectedIndexChanged += self.dropDownOutput  #.Click+= registers the press of the button to register the event handler and determine what action takes place when button clicked
        self.Controls.Add(cBox)

        #############-------------\-------------#############

        #Create ok button
        btnOk = Button()  #create a button control
        btnOk.Text = "Next"
        btnOk.Location = Point(uiWidth - ((btnOk.Width * 2) + spacing),
                               uiHeight - (btnOk.Height + spacing))
        btnOk.Anchor = (AnchorStyles.Bottom | AnchorStyles.Right)
        btnOk.Click += self.okButtonPressed  #Register the event on the button bress to trigger the def okButtonPressed
        self.Controls.Add(btnOk)

        #Create Cancel Button
        btnCancel = Button()
        #btnCancel.Parent = self
        btnCancel.Text = "Cancel"
        btnCancel.Location = Point(uiWidth - (btnOk.Width + spacing),
                                   uiHeight - (btnOk.Height + spacing))
        btnCancel.Anchor = (AnchorStyles.Bottom | AnchorStyles.Right)
        btnCancel.Click += self.CnlButtonPressed
        self.Controls.Add(btnCancel)