示例#1
0
    def __init__(self):
        """PrintPreviewDialogSample class init function."""
        # initialize a PrintDocument object
        self.doc_to_print = PrintDocument()

        # setup title
        self.Text = "PrintPreviewDialog control"

        # setup button
        self.button = Button()
        self.button.Text = "PrintPreviewDialog"
        self.button.Click += self.click
        self.button.Width = 150

        # setup printpreviewdialog
        self.printpreviewdialog = PrintPreviewDialog()
        self.printpreviewdialog.Text = "PrintPreviewDialog"
        self.printpreviewdialog.ClientSize = Size(500, 300)
        self.printpreviewdialog.Location = Point(29, 29)
        self.printpreviewdialog.MinimumSize = Size(375, 250)
        self.printpreviewdialog.UseAntiAlias = True
        self.printpreviewdialog.Document = self.doc_to_print
        self.doc_to_print.PrintPage += self.doc_to_print_PrintPage

        # add controls
        self.Controls.Add(self.button)
    def __build_advancedtab(self):
        ''' builds and returns the "Advanced" Tab for the TabControl '''

        tabpage = TabPage()
        tabpage.Text = i18n.get("ConfigFormAdvancedTab")

        # 1. --- a description label for this tabpage
        label = Label()
        label.UseMnemonic = False
        label.AutoSize = True
        label.Location = Point(14, 25)
        label.Size = Size(299, 17)
        label.Text = i18n.get("ConfigFormAdvancedText")

        # 2. --- build the update checklist (contains all the 'data' checkboxes)
        tbox = RichTextBox()
        tbox.Multiline = True
        tbox.MaxLength = 65536
        tbox.WordWrap = True
        tbox.Location = Point(15, 50)
        tbox.Size = Size(355, 200)

        menu = ContextMenu()
        items = menu.MenuItems
        items.Add(MenuItem(i18n.get("TextCut"), lambda s, ea: tbox.Cut()))
        items.Add(MenuItem(i18n.get("TextCopy"), lambda s, ea: tbox.Copy()))
        items.Add(MenuItem(i18n.get("TextPaste"), lambda s, ea: tbox.Paste()))
        tbox.ContextMenu = menu
        self.__advanced_tbox = tbox

        # 3. --- add 'em all to the tabpage
        tabpage.Controls.Add(label)
        tabpage.Controls.Add(self.__advanced_tbox)

        return tabpage
示例#3
0
    def __build_gui(self):
        ''' Constructs and initializes the gui for this form. '''

        # 1. --- build each gui component
        self.__progbar = self.__build_progbar()
        self.__label = self.__build_label()
        self.__pbox_panel = self.__build_pboxpanel()
        self.__cancel_button = self.__build_cancelbutton()

        # 2. -- configure this form, and add all the gui components to it
        self.Text = self.Text = Resources.SCRIPT_FULLNAME
        self.AutoScaleMode = AutoScaleMode.Font
        self.ClientSize = Size(346, 604)
        self.MinimumSize = Size(166, 275)
        self.FormBorderStyle = FormBorderStyle.Sizable
        self.Icon = None

        self.Controls.Add(self.__progbar)
        self.Controls.Add(self.__label)
        self.Controls.Add(self.__pbox_panel)
        self.Controls.Add(self.__cancel_button)

        # 3. -- set up some listeners
        self.__scraper.start_scrape_listeners.append(self.__start_scrape)
        self.__scraper.cancel_listeners.append(self.close_threadsafe)
        self.FormClosing += self.__form_closing_fired
        self.FormClosed += self.__form_closed_fired

        # 4. -- define the keyboard focus tab traversal ordering
        self.__cancel_button.TabIndex = 0
示例#4
0
    def _initialize_components(self):
        self._generate_menu_strip()
        self._create_buttons()

        flags_description = Label()
        flags_description.Parent = self
        flags_description.Text = 'Flags:'
        flags_description.Location = Point(10, 30)
        flags_description.Size = TextRenderer.MeasureText(
            flags_description.Text, flags_description.DefaultFont)

        self._result = Label()
        self._result.Parent = self
        self._result.Text = ''
        self._result.Size = TextRenderer.MeasureText(self._result.Text,
                                                     self._result.DefaultFont)
        self._result.Location = Point(
            self.Size.Width / 2 - self._result.Size.Width / 2 - 5, 30)

        self._flags_counter = Label()
        self._flags_counter.Parent = self
        self._flags_counter.Location = Point(45, 30)
        self._flags_counter.Size = Size(30, 20)

        self._label_timer = Label()
        self._label_timer.Parent = self
        self._label_timer.TextAlign = ContentAlignment.MiddleRight
        self._label_timer.Location = Point(self.Size.Width - 70, 30)
        self._label_timer.Size = Size(40, 20)
示例#5
0
    def _generate_menu_strip(self):
        menu_strip = MenuStrip()
        menu_strip.Parent = self

        file_item = ToolStripMenuItem("File")
        menu_strip.Items.Add(file_item)

        new_game = ToolStripMenuItem("New game")
        file_item.DropDownItems.Add(new_game)

        self._easy = ToolStripMenuItem("Easy")
        self._easy.Click += self._on_new_game_click
        new_game.DropDownItems.Add(self._easy)

        self._normal = ToolStripMenuItem("Normal")
        self._normal.Click += self._on_new_game_click
        new_game.DropDownItems.Add(self._normal)

        self._hard = ToolStripMenuItem("Hard")
        self._hard.Click += self._on_new_game_click
        new_game.DropDownItems.Add(self._hard)

        self._new_game_handlers = []

        self.checkBox = CheckBox()
        self.checkBox.Text = "Nightmare"
        self.checkBox.Size = Size(100, 20)
        self.checkBox.Checked = False
        nightmare = ToolStripControlHost(self.checkBox)
        nightmare.Size = Size(100, 20)
        new_game.DropDownItems.Add(nightmare)

        self._exit = ToolStripMenuItem("Exit")
        self._exit.Click += self._exit_game
        file_item.DropDownItems.Add(self._exit)
示例#6
0
    def __init__(self, itemlist):

        height = len(itemlist) * 17
        self.Text = "Select the categories to export"
        self.Size = Size(300, height + 80)

        self.check = CheckedListBox()
        self.check.Parent = self
        self.check.Location = Point(5, 5)
        self.check.Size = Size(270, height)

        # load the list of relevant categories found in the project
        list_items = List[Object](itemlist)
        self.check.Items.AddRange(list_items.ToArray())
        self.check.CheckOnClick = True

        # set checked by default
        for i in range(len(itemlist)):
            self.check.SetItemChecked(i, True)

        okay = Button()
        okay.Parent = self
        okay.Text = 'OK'
        okay.Location = Point(50, height + 10)
        okay.Width = 140
        okay.Click += self.onValidate

        cancel = Button()
        cancel.Parent = self
        cancel.Text = 'Cancel'
        cancel.Location = Point(okay.Right, height + 10)
        cancel.Click += self.onCancel

        self.CenterToScreen()
    def __init__(self):
        self.textBox1 = WinForms.TextBox()
        self.button1 = WinForms.Button()
        self.SuspendLayout()

        # textBox1
        self.textBox1.Location = Point(156, 48)
        self.textBox1.Name = "textBox1"
        self.textBox1.Size = Size(290, 21)
        self.textBox1.TabIndex = 0
        self.textBox1.Text = "Helllo World"

        # button1
        self.button1.Location = Point(156, 140)
        self.button1.Name = "button1"
        self.button1.Size = Size(147, 23)
        self.button1.TabIndex = 1
        self.button1.Text = "Click Me"
        self.button1.UseVisualStyleBackColor = True
        self.button1.Click += self.button_Click

        # Form1
        self.AutoScaleMode = WinForms.AutoScaleMode.Font
        self.ClientSize = Size(709, 354)
        self.Controls.Add(self.button1)
        self.Controls.Add(self.textBox1)
        self.Name = "Form1"
        self.Text = "Form1"
        self.ResumeLayout(False)
        self.PerformLayout()
示例#8
0
   def __build_label(self, series_ref):
      ''' builds and returns the main text label for this form '''

      # 1. compute the best possible full name for the given SeriesRef   
      name_s = series_ref.series_name_s
      publisher_s = series_ref.publisher_s
      vol_year_n = series_ref.volume_year_n
      vol_year_s = sstr(vol_year_n) if vol_year_n > 0 else ''
      fullname_s = ''
      if name_s:
         if publisher_s:
            if vol_year_s:
               fullname_s = "'"+name_s+"' ("+publisher_s+", " + vol_year_s + ")"
            else:
               fullname_s = "'"+name_s+"' (" + publisher_s + ")"
         else:
            fullname_s = "'"+name_s+"'"
            
      
      label = Label()
      label.UseMnemonic = False
      sep = '  ' if len(fullname_s) > 40 else '\n'
      label.Text = i18n.get("IssueFormChooseText").format(fullname_s, sep)
         
      if self.__config.show_covers_b:
         label.Location = Point(218, 20)
         label.Size = Size(480, 40)
      else:
         label.Location = Point(10, 20)
         label.Size = Size(680, 40)
      
      return label
    def __init__(self, posx, posy, hight, width, title, curvlaue, name):
        super(金额Entry, self).__init__(self)
        self.格式说明 = "数值,或者类似 5吨*3元每吨*付款比例30%-扣减金额1000"
        # self.Font= Font("楷体_GB2312", 24);
        self.Notify = None
        self.curvalue = self.格式说明
        self.ctrlwidth = width / 2
        self.Location = Point(posx, posy)
        self.Size = Size(width, hight)
        self.title = title
        self.name = name

        # fontsize = self.ClientSize.Height*7/10
        # print(self.ClientSize.Height ,self.Size.Height )
        self.Font = self.getFont()

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

        self.cb = TextBox()
        self.cb.Parent = self
        self.cb.Location = Point(self.ctrlwidth, 0)
        self.cb.Size = Size(self.ctrlwidth, hight)
        self.cb.Text = self.curvalue
        self.cb.Font = self.Font
        self.cb.ForeColor = Color.Blue
        self.cb.TextChanged += self.OnChanged
    def __init__(self, posx, posy, hight, width, title, curvlaue, name):
        super(generalEntry, self).__init__(self)
        self.格式说明 = "不能为空"

        self.Notify = None
        self.curvalue = self.格式说明
        # self.Width = width
        self.ctrlwidth = width / 2
        # self.Height =hight
        self.Size = Size(width, hight)
        self.Location = Point(posx, posy)
        self.title = title
        self.name = name

        self.Font = self.getFont()

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

        self.cb = TextBox()
        self.cb.Parent = self
        self.cb.Location = Point(self.ctrlwidth, 0)
        self.cb.Size = Size(self.ctrlwidth, hight)
        self.cb.Text = self.curvalue
        self.cb.Font = self.Font
        self.cb.ForeColor = Color.Blue
        self.cb.TextChanged += self.OnChanged
示例#11
0
    def __init__(self):
        self.StartPosition = FormStartPosition.CenterScreen
        self.FormBorderStyle = FormBorderStyle.FixedDialog
        self.Text = 'Текст'
        self.Name = 'Имя'
        self.Size = Size(500, 250)
        self.MaximizeBox = False
        self.MinimizeBox = False
        self.msg = []

        gb = GroupBox()
        gb.Text = "Категории"
        gb.Size = Size(120, 110)
        gb.Location = Point(20, 20)
        gb.Parent = self

        j = 25
        for c in cats:
            self.cb = CheckBox()
            self.cb.Text = c
            self.cb.Location = Point(25, j)
            j += 25
            self.cb.Width = 200
            self.cb.Checked += self.OnChanged
            gb.Size = Size(120, 20 + j)
            gb.Controls.Add(self.cb)

        self.label = Label()
        self.label.Text = "Результат"
        self.label.Location = Point(225, 20)
        self.label.Height = 25
        self.label.Width = 225
        self.Controls.Add(self.label)
        self.label.Text = "".join(self.msg)
示例#12
0
 def init(self):
     self.ClientSize = Size(820, 620)
     charting = Charting
     chart = charting.Chart()
     chart.Location = Point(10, 10)
     chart.Size = Size(800, 600)
     chart.ChartAreas.Add('iterations')
     area = chart.ChartAreas['iterations']
     x = area.AxisX
     x.Minimum = self.xmin
     x.Maximum = self.xmax
     x.Interval = self.xstp
     x.MajorGrid.LineColor = Color.White
     x.MajorGrid.LineDashStyle = charting.ChartDashStyle.NotSet
     y = area.AxisY
     y.Minimum = self.ymin
     y.Maximum = self.ymax
     y.Interval = self.ystp
     y.MajorGrid.LineColor = Color.Black
     y.MajorGrid.LineDashStyle = charting.ChartDashStyle.Dash
     for name, attr in self.series.iteritems():
         color = attr['color']
         linewidth = attr['linewidth']
         chart.Series.Add(name)
         series = chart.Series[name]
         series.ChartType = charting.SeriesChartType.Line
         series.Color = Color.FromArgb(*color)
         series.BorderWidth = linewidth
         keys = sorted(attr['data'].keys(), key=int)
         for key in keys:
             value = attr['data'][key]
             series.Points.AddXY(int(key), value)
     area.BackColor = Color.White
     self.Controls.Add(chart)
示例#13
0
    def __init__(self):
        self.Text = "Hello World From Python"
        self.AutoScaleBaseSize = Size(5, 13)
        self.ClientSize = Size(392, 117);
        h = WinForms.SystemInformation.CaptionHeight
        self.MinimumSize = Size(392, (117 + h))

        # Create the button
        self.button = WinForms.Button()
        self.button.Location = Point(160, 64)
        self.button.Size = Size(820, 20)
        self.button.TabIndex = 2
        self.button.Text = "Click Me!"
        
        # Register the event handler
        self.button.Click += self.button_Click

        # Create the text box
        self.textbox = WinForms.TextBox()
        self.textbox.Text = "Hello World"
        self.textbox.TabIndex = 1
        self.textbox.Size = Size(1260, 40)
        self.textbox.Location = Point(160, 24)
        
        # Add the controls to the form
        self.AcceptButton = self.button
        self.Controls.Add(self.button);
        self.Controls.Add(self.textbox);
示例#14
0
        def __init__(self, title, url, width, height, resizable, fullscreen,
                     min_size, webview_ready):
            self.Text = title
            self.AutoScaleBaseSize = Size(5, 13)
            self.ClientSize = Size(width, height)
            self.MinimumSize = Size(min_size[0], min_size[1])

            # Application icon
            try:  # Try loading an icon embedded in the exe file. This will crash when frozen with PyInstaller
                handler = windll.kernel32.GetModuleHandleW(None)
                icon_handler = windll.user32.LoadIconW(handler, 1)
                self.Icon = Icon.FromHandle(
                    IntPtr.op_Explicit(Int32(icon_handler)))
            except:
                pass

            self.webview_ready = webview_ready

            self.web_browser = WinForms.WebBrowser()
            self.web_browser.Dock = WinForms.DockStyle.Fill

            if url:
                self.web_browser.Navigate(url)

            self.Controls.Add(self.web_browser)
            self.is_fullscreen = False
            self.Shown += self.on_shown

            if fullscreen:
                self.toggle_fullscreen()
    def __init__(self, title, author):
        # Create the form
        self.Name = "Create Window"
        self.Text = title
        self.Size = Size(500, 150)
        self.CenterToScreen()

        self.value = ""

        # Create label for input title
        labelDiv = Label(Text=author + ":")
        labelDiv.Parent = self
        labelDiv.Size = Size(250, 250)
        labelDiv.Location = Point(30, 20)

        # Create TextBox for input
        self.textboxDiv = TextBox()
        self.textboxDiv.Parent = self
        self.textboxDiv.Text = "Date 1"
        self.textboxDiv.Size = Size(150, 150)
        self.textboxDiv.Location = Point(300, 20)

        # Create button
        button = Button()
        button.Parent = self
        button.Text = "Ok"
        button.Location = Point(300, 60)

        # Register event
        button.Click += self.ButtonClicked
    def __init__(self, chracters):
        self.existingchracters = chracters
        self.TextBox = TextBox()
        self.TextBox.Size = Size(250, 20)
        self.TextBox.Location = Point(15, 12)
        self.TextBox.TabIndex = 1
        self.TextBox.MaxLength = 1

        self.OK = Button()
        self.OK.Text = "OK"
        self.OK.Size = Size(75, 23)
        self.OK.Location = Point(109, 38)
        self.OK.DialogResult = DialogResult.OK
        self.OK.Click += self.CheckTextBox

        self.Cancel = Button()
        self.Cancel.Size = Size(75, 23)
        self.Cancel.Text = "Cancel"
        self.Cancel.Location = Point(190, 38)
        self.Cancel.DialogResult = DialogResult.Cancel

        self.Size = Size(300, 100)
        self.Text = "Please enter the character"
        self.Controls.Add(self.OK)
        self.Controls.Add(self.Cancel)
        self.Controls.Add(self.TextBox)
        self.AcceptButton = self.OK
        self.CancelButton = self.Cancel
        self.FormBorderStyle = FormBorderStyle.FixedDialog
        self.StartPosition = FormStartPosition.CenterParent
        self.Icon = System.Drawing.Icon(ICON)
        self.ActiveControl = self.TextBox
示例#17
0
 def init(self):
     # table
     table = make_table('main', False)
     table.Size = Size(580, 700)
     table.Location = Point(10, 10)
     table.ColumnCount = 2
     table.Columns[0].Name = 'Key'
     table.Columns[0].SortMode = DataGridViewColumnSortMode.NotSortable
     table.Columns[0].ReadOnly = True
     table.Columns[0].DefaultCellStyle.SelectionBackColor = Color.FromArgb(238, 238, 238)
     table.Columns[0].DefaultCellStyle.BackColor = Color.FromArgb(238, 238, 238)
     table.Columns[1].Name = 'Value'
     table.Columns[1].SortMode = DataGridViewColumnSortMode.NotSortable
     keys = sorted(self.settings.keys())
     for key in keys:
         table.Rows.Add(key, self.settings[key])
     self.table = table
     # buttons
     ok = Button()
     ok.Text = 'OK'
     ok.DialogResult = DialogResult.OK
     cancel = Button()
     cancel.Text = 'Cancel'
     cancel.DialogResult = DialogResult.Cancel
     buttons = FlowLayoutPanel()
     buttons.FlowDirection = FlowDirection.RightToLeft
     # buttons.BorderStyle = BorderStyle.None
     buttons.Controls.Add(cancel)
     buttons.Controls.Add(ok)
     buttons.Size = Size(580, 30)
     buttons.Location = Point(10, 720)
     # layout
     self.ClientSize = Size(600, 800)
     self.Controls.Add(table)
     self.Controls.Add(buttons)
示例#18
0
 def __init__(self):
     self.Size = Size(200, 200)
     self.FormBorderStyle = FormBorderStyle.Sizable
     self._btn = Button()
     self._btn.Parent = self
     self._btn.Location = Point(0, 0)
     self._btn.Size = Size(20, 20)
    def __init__(self, contents):
        self.Contents = contents

        self.BackColor = Color.FromArgb(25, 25, 25)
        self.ForeColor = Color.FromArgb(231, 231, 231)
        self.Size = Size(500, 400)
        self.Text = '{0} - v{1}'.format(self.ScriptName, self.CurVer)

        self.DataGridSetup()

        self.cbHide = CheckBox()
        self.cbHide.Text = 'Hide'
        self.cbHide.Checked = True
        self.cbHide.BackColor = Color.FromArgb(25, 25, 25)
        self.cbHide.Location = Point(342, 326)
        self.cbHide.Size = Size(50, 30)

        self.btnGet = Button()
        self.btnGet.Text = 'Get'
        self.btnGet.BackColor = Color.FromArgb(50, 50, 50)
        self.btnGet.Location = Point(422, 324)
        self.btnGet.Size = Size(50, 30)
        self.btnGet.FlatStyle = FlatStyle.Flat
        self.btnGet.FlatAppearance.BorderSize = 1
        self.btnGet.Click += self.btnGetPressed

        self.Controls.Add(self.DataGrid)
        self.Controls.Add(self.cbHide)
        self.Controls.Add(self.btnGet)
示例#20
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)
示例#21
0
        def __init__(self, window):
            self.uid = window.uid
            self.pywebview_window = window
            self.real_url = None
            self.Text = window.title
            self.ClientSize = Size(window.width, window.height)
            self.MinimumSize = Size(window.min_size[0], window.min_size[1])
            self.BackColor = ColorTranslator.FromHtml(window.background_color)

            if window.x is not None and window.y is not None:
                self.move(window.x, window.y)
            else:
                self.StartPosition = WinForms.FormStartPosition.CenterScreen

            self.AutoScaleDimensions = SizeF(96.0, 96.0)
            self.AutoScaleMode = WinForms.AutoScaleMode.Dpi

            if not window.resizable:
                self.FormBorderStyle = WinForms.FormBorderStyle.FixedSingle
                self.MaximizeBox = False

            # Application icon
            handle = windll.kernel32.GetModuleHandleW(None)
            icon_handle = windll.shell32.ExtractIconW(handle, sys.executable, 0)

            if icon_handle != 0:
                self.Icon = Icon.FromHandle(IntPtr.op_Explicit(Int32(icon_handle))).Clone()

            windll.user32.DestroyIcon(icon_handle)

            self.shown = window.shown
            self.loaded = window.loaded
            self.url = window.url
            self.text_select = window.text_select

            self.is_fullscreen = False
            if window.fullscreen:
                self.toggle_fullscreen()

            if window.frameless:
                self.frameless = window.frameless
                self.FormBorderStyle = 0

            if is_cef:
                CEF.create_browser(window, self.Handle.ToInt32(), BrowserView.alert)
            elif is_edge:
                self.browser = BrowserView.EdgeHTML(self, window)
            else:
                self.browser = BrowserView.MSHTML(self, window)

            self.Shown += self.on_shown
            self.FormClosed += self.on_close

            if is_cef:
                self.Resize += self.on_resize

            if window.confirm_close:
                self.FormClosing += self.on_closing
示例#22
0
        def __init__(self, window):
            self.uid = window.uid
            self.pywebview_window = window
            self.url = None
            self.Text = window.title
            self.Size = Size(window.initial_width, window.initial_height)
            self.MinimumSize = Size(window.min_size[0], window.min_size[1])
            self.BackColor = ColorTranslator.FromHtml(window.background_color)

            if window.initial_x is not None and window.initial_y is not None:
                self.move(window.initial_x, window.initial_y)
            else:
                self.StartPosition = WinForms.FormStartPosition.CenterScreen

            self.AutoScaleDimensions = SizeF(96.0, 96.0)
            self.AutoScaleMode = WinForms.AutoScaleMode.Dpi

            if not window.resizable:
                self.FormBorderStyle = WinForms.FormBorderStyle.FixedSingle
                self.MaximizeBox = False

            if window.minimized:
                self.WindowState = WinForms.FormWindowState.Minimized

            # Application icon
            handle = windll.kernel32.GetModuleHandleW(None)
            icon_path = os.path.join(os.path.dirname(os.path.realpath(importlib.util.find_spec("bcml").origin)), "data", "bcml.ico")
            icon_handle = windll.shell32.ExtractIconW(handle, icon_path, 0)

            if icon_handle != 0:
                self.Icon = Icon.FromHandle(
                    IntPtr.op_Explicit(Int32(icon_handle))
                ).Clone()

            windll.user32.DestroyIcon(icon_handle)

            self.closed = window.closed
            self.closing = window.closing
            self.shown = window.shown
            self.loaded = window.loaded
            self.url = window.url
            self.text_select = window.text_select
            self.on_top = window.on_top

            self.is_fullscreen = False
            if window.fullscreen:
                self.toggle_fullscreen()

            if window.frameless:
                self.frameless = window.frameless
                self.FormBorderStyle = 0
            CEF.create_browser(window, self.Handle.ToInt32(), BrowserView.alert)

            self.Shown += self.on_shown
            self.FormClosed += self.on_close
            self.FormClosing += self.on_closing

            self.Resize += self.on_resize
示例#23
0
        def __init__(self, title, url, width, height, resizable, fullscreen,
                     min_size, confirm_quit, background_color, debug,
                     webview_ready):
            self.Text = title
            self.ClientSize = Size(width, height)
            self.MinimumSize = Size(min_size[0], min_size[1])
            self.BackColor = ColorTranslator.FromHtml(background_color)

            if not resizable:
                self.FormBorderStyle = WinForms.FormBorderStyle.FixedSingle
                self.MaximizeBox = False

            # Application icon
            handle = windll.kernel32.GetModuleHandleW(None)
            icon_handle = windll.shell32.ExtractIconW(handle, sys.executable,
                                                      0)

            if icon_handle != 0:
                self.Icon = Icon.FromHandle(
                    IntPtr.op_Explicit(Int32(icon_handle))).Clone()

            windll.user32.DestroyIcon(icon_handle)

            self.webview_ready = webview_ready

            self.web_browser = WinForms.WebBrowser()
            self.web_browser.Dock = WinForms.DockStyle.Fill
            self.web_browser.ScriptErrorsSuppressed = True
            self.web_browser.IsWebBrowserContextMenuEnabled = False
            self.web_browser.WebBrowserShortcutsEnabled = False

            # HACK. Hiding the WebBrowser is needed in order to show a non-default background color. Tweaking the Visible property
            # results in showing a non-responsive control, until it is loaded fully. To avoid this, we need to disable this behaviour
            # for the default background color.
            if background_color != '#FFFFFF':
                self.web_browser.Visible = False
                self.first_load = True
            else:
                self.first_load = False

            self.cancel_back = False
            self.web_browser.PreviewKeyDown += self.on_preview_keydown
            self.web_browser.Navigating += self.on_navigating
            self.web_browser.DocumentCompleted += self.on_document_completed

            if url:
                self.web_browser.Navigate(url)

            self.Controls.Add(self.web_browser)
            self.is_fullscreen = False
            self.Shown += self.on_shown

            if confirm_quit:
                self.FormClosing += self.on_closing

            if fullscreen:
                self.toggle_fullscreen()
示例#24
0
    def __init__(self):
        self.OrcaThread = ProcessThread()
        self.Text = "Orca v1"
        self.Size = Size(870, 820)

        mainMenu = MainMenu()
        menuItem1 = MenuItem()
        menuItem2 = MenuItem()
        menuItem1.Text = "File"
        menuItem2.Text = "Hello"
        menuItem2.Click += self.SleepTest
        #menuItem1.Click += self.Disabler
        #mainMenu.MenuItems.Add(menuItem1)
        #mainMenu.MenuItems.Add(menuItem2)
        self.Menu = mainMenu

        self.tabControl1 = TabControl()
        self.tabPage1 = TabPage()
        self.tabPage1.Text = "Old Citrix"
        self.tabPage2 = TabPage()
        self.tabPage2.Text = "New Citrix"
        self.tabControl1.Size = Size(835, 420)
        self.tabControl1.Location = Point(10, 15)

        self.tabControl1.Parent = self
        self.tabControl1.Controls.Add(self.tabPage1)
        self.tabControl1.Controls.Add(self.tabPage2)

        self.userBox = TextBox()
        self.userBox.Location = Point(80, 50)
        self.userBox.Width = 220
        self.userBox.Parent = self.tabPage1
        label = Label()
        label.Text = "Username"
        label.Location = Point(10, 50)
        label.Parent = self.tabPage1
        btn_MigrateOld = Button()
        btn_MigrateOld.Text = "Migrate Old!"
        btn_MigrateOld.Location = Point(320, 50)
        btn_MigrateOld.Click += self.MigrateOld
        btn_MigrateOld.Parent = self.tabPage1

        self.tbox = RichTextBox()
        self.tbox.Parent = self
        self.tbox.Location = Point(10, 450)
        self.tbox.Multiline = True
        self.tbox.Width = 835
        self.tbox.Height = 300
        self.tbox.BackColor = Color.Black
        self.tbox.ForeColor = Color.LightGreen
        self.tbox.ScrollBars = ScrollBars.Vertical
        self.tbox.ReadOnly = True
        self.tbox.HideSelection = False
        self.tbox.DetectUrls = False

        self.Load += self.Loaded
示例#25
0
    def __init__(self):
        self.BackColor = Color.LightGray
        self.CenterToScreen()
        self.Text = 'Window_text'
        self.Size = Size(200, 200)

        self.label = Label()
        self.label.Parent = self
        self.label.Text = "HELLO"
        self.label.Location = Point(75, 75)
        self.label.Size = Size(200, 200)
示例#26
0
    def showBox(self):
        '''
        set the remaining box controls and launch
        '''
        self.buttonpanel = Panel()
        self.buttonpanel.Parent = self
        self.buttonpanel.Location = Point(0, self.panel.Bottom)
        self.buttonpanel.Size = Size(Fconfig.smwidth, 2 * Fconfig.unitline)
        self.buttonpanel.Dock = DockStyle.Bottom

        self.warning = Label()
        self.warning.Parent = self.buttonpanel
        self.warning.Location = Point(Fconfig.margin, 0)
        self.warning.Size = Size(Fconfig.smwidth, Fconfig.unitline)
        self.warning.Font = Font(Fconfig.basefont, Fconfig.sizefont,
                                 FontStyle.Bold)
        self.warning.ForeColor = Color.Coral
        self.warning.TextAlign = ContentAlignment.MiddleCenter

        okay = Button()
        okay.Parent = self.buttonpanel
        okay.Text = Fconfig.buttonOK
        okay.Location = Point(50, Fconfig.unitline)
        okay.Width = 140
        okay.Click += self.onValidate
        okay.Anchor = AnchorStyles.Right

        cancel = Button()
        cancel.Text = Fconfig.buttonCANCEL
        cancel.Parent = self.buttonpanel
        cancel.Location = Point(okay.Right, Fconfig.unitline)
        cancel.Click += self.onCancel
        cancel.Anchor = AnchorStyles.Right

        self.Width = Fconfig.width
        self.Height = self.panel.Bottom + 105
        self.CenterToScreen()

        ModeDBG.say('\npanel top :{0}, bottom :{1}'.format(
            self.panel.Top, self.panel.Bottom))
        ModeDBG.say('\n\nPanel loaded with {0} items\n'.format(
            len(self.panelparams)))

        # Display the form
        try:
            if Application.MessageLoop:
                TaskDialog.Show('UserForm', 'Another window is running...')
            else:
                Application.Run(self)

        except:
            TaskDialog.Show('UserForm', 'Loading failed...')
示例#27
0
        def __init__(self, uid, title, url, width, height, resizable, fullscreen, min_size,
                     confirm_quit, background_color, debug, js_api, text_select, frameless, webview_ready):
            self.uid = uid
            self.Text = title
            self.ClientSize = Size(width, height)
            self.MinimumSize = Size(min_size[0], min_size[1])
            self.BackColor = ColorTranslator.FromHtml(background_color)

            self.AutoScaleDimensions = SizeF(96.0, 96.0)
            self.AutoScaleMode = WinForms.AutoScaleMode.Dpi

            if not resizable:
                self.FormBorderStyle = WinForms.FormBorderStyle.FixedSingle
                self.MaximizeBox = False

            # Application icon
            handle = windll.kernel32.GetModuleHandleW(None)
            icon_handle = windll.shell32.ExtractIconW(handle, sys.executable, 0)

            if icon_handle != 0:
                self.Icon = Icon.FromHandle(IntPtr.op_Explicit(Int32(icon_handle))).Clone()

            windll.user32.DestroyIcon(icon_handle)

            self.webview_ready = webview_ready
            self.load_event = Event()
            self.background_color = background_color
            self.url = url

            self.is_fullscreen = False
            if fullscreen:
                self.toggle_fullscreen()

            if frameless:
                self.frameless = frameless
                self.FormBorderStyle = 0

            if is_cef:
                CEF.create_browser(self.uid, self.Handle.ToInt32(), BrowserView.alert, url, js_api)
            else:
                self._create_mshtml_browser(url, js_api, debug)

            self.text_select = text_select
            self.Shown += self.on_shown
            self.FormClosed += self.on_close

            if is_cef:
                self.Resize += self.on_resize

            if confirm_quit:
                self.FormClosing += self.on_closing
示例#28
0
    def init(self):
        """Initialize the form.

        Returns
        -------
        None

        """
        w = self.chartwidth + self.padding[1] + self.padding[3]
        h = self.chartheight + self.padding[0] + self.padding[2]
        self.ClientSize = Size(w, h)

        charting = Charting
        chart = charting.Chart()
        chart.Location = Point(self.padding[3], self.padding[0])
        chart.Size = Size(self.chartwidth, self.chartheight)
        chart.ChartAreas.Add('series')
        area = chart.ChartAreas['series']

        x = area.AxisX
        x.Minimum = self.xmin
        x.Maximum = self.xmax
        x.Interval = self.xstep
        x.MajorGrid.LineColor = Color.White
        x.MajorGrid.LineDashStyle = charting.ChartDashStyle.NotSet

        y = area.AxisY
        y.Minimum = self.ymin
        y.Maximum = self.ymax
        y.Interval = self.ystep
        y.MajorGrid.LineColor = Color.Gray
        y.MajorGrid.LineDashStyle = charting.ChartDashStyle.Dot

        for attr in self.series:
            name = attr['name']
            color = attr['color']
            linewidth = attr['linewidth']
            chart.Series.Add(name)
            series = chart.Series[name]
            series.ChartType = charting.SeriesChartType.Line
            series.Color = Color.FromArgb(*color)
            series.BorderWidth = linewidth
            keys = sorted(attr['data'].keys(), key=int)
            for key in keys:
                value = attr['data'][key]
                series.Points.AddXY(int(key), value)

        area.BackColor = self.bgcolor

        self.Controls.Add(chart)
    def __build_comicvinetab(self):
        ''' builds and returns the "ComicVine" Tab for the TabControl '''

        tabpage = TabPage()
        tabpage.Text = i18n.get("ConfigFormComicVineTab")
        tabpage.Name = "comicvine"

        # 1. --- a description label for this tabpage
        label = Label()
        label.UseMnemonic = False
        label.AutoSize = False
        label.Location = Point(34, 80)
        label.Size = Size(315, 54)
        label.Text = i18n.get("ConfigFormComicVineText")

        # 2. --- the API key text box
        fired_update_gui = self.__fired_update_gui

        class ApiKeyTextBox(TextBox):
            def OnTextChanged(self, args):
                fired_update_gui()

        self.__api_key_tbox = ApiKeyTextBox()
        tbox = self.__api_key_tbox
        tbox.Location = Point(34, 135)
        tbox.Size = Size(315, 1)

        menu = ContextMenu()
        items = menu.MenuItems
        items.Add(MenuItem(i18n.get("TextCut"), lambda s, ea: tbox.Cut()))
        items.Add(MenuItem(i18n.get("TextCopy"), lambda s, ea: tbox.Copy()))
        items.Add(MenuItem(i18n.get("TextPaste"), lambda s, ea: tbox.Paste()))
        tbox.ContextMenu = menu

        # 3. --- add a clickable link to send the user to ComicVine
        linklabel = LinkLabel()
        linklabel.UseMnemonic = False
        linklabel.AutoSize = False
        linklabel.Location = Point(34, 170)
        linklabel.Size = Size(315, 34)
        linklabel.Text = i18n.get("ConfigFormComicVineClickHere")
        linklabel.LinkClicked += self.__fired_linkclicked

        # 4. --- add 'em all to this tabpage
        tabpage.Controls.Add(label)
        tabpage.Controls.Add(tbox)
        tabpage.Controls.Add(linklabel)

        return tabpage
def DodajFunkciju(frm):
    operacija = ToolStripMenuItem(Text='Sinus',
                                  Name='runSin',
                                  Size=Size(130, 25))
    operacija.Tag = frm
    operacija.Click += sinFunction
    frm.addedOperaionsToolStripMenuItem.DropDownItems.Add(operacija)