Esempio n. 1
0
 def __init__(self):
     self.Text = "SolverStudio"
     self.FormBorderStyle = FormBorderStyle.FixedDialog
     self.Height = 150
     self.Width = 400
     self.label1 = Label()
     self.label1.Text = "Pyomo is not installed by default in SolverStudio. You should install it yourself from the link below.\n\nBe sure to add the location of 'pyomo.exe' (usually '\\PythonXY\\Scripts') to the system path environment variable."
     self.label1.Location = Point(10, 10)
     self.label1.Height = 75
     self.label1.Width = 380
     self.myOK = Button()
     self.myOK.Text = "OK"
     self.myOK.Location = Point(310, 90)
     self.myOK.Click += self.CloseForm
     self.link1 = LinkLabel()
     self.link1.Location = Point(10, 95)
     self.link1.Width = 380
     self.link1.Height = 20
     self.link1.LinkClicked += VisitPYOMODownloadPage
     self.link1.VisitedLinkColor = Color.Blue
     self.link1.LinkBehavior = LinkBehavior.HoverUnderline
     self.link1.LinkColor = Color.Navy
     self.link1.Text = 'http://www.pyomo.org/installation/'
     self.link1.LinkArea = LinkArea(0, 49)
     self.AcceptButton = self.myOK
     self.Controls.Add(self.myOK)
     self.Controls.Add(self.link1)
     self.Controls.Add(self.label1)
     self.CenterToScreen()
Esempio n. 2
0
        def __init__(self):
            self.Text = "SolverStudio: NEOS Warning"
            self.FormBorderStyle = FormBorderStyle.FixedDialog
            self.Height = 235
            self.Width = 310
            # self.Warning = Label()
            # self.Warning.Text = "Models solved using via NEOS will be available in the public domain for perpetuity."
            # self.Warning.Location = Point(10,10)
            # self.Warning.Height  = 30
            # self.Warning.Width = 380

            self.myOK = Button()
            self.myOK.Text = "Continue"
            self.myOK.Width = 100
            self.myOK.Location = Point(self.Width / 2 - self.myOK.Width - 30,
                                       self.Height - 65)
            self.myOK.Click += self.AddChoice

            self.myCancel = Button()
            self.myCancel.Text = "Cancel"
            self.myCancel.Width = 100
            self.myCancel.Location = Point(self.Width / 2 + 30,
                                           self.Height - 65)

            self.check1 = CheckBox()
            self.check1.Text = "Never show NEOS warnings again."
            self.check1.Location = Point(12, 80)
            self.check1.Width = 250
            self.check1.Height = 130

            self.link1 = LinkLabel()
            self.link1.Location = Point(10, 10)
            self.link1.Width = self.Width - 15
            self.link1.Height = 120
            self.link1.LinkClicked += self.OpenTCs
            self.link1.VisitedLinkColor = Color.Blue
            self.link1.LinkBehavior = LinkBehavior.HoverUnderline
            self.link1.LinkColor = Color.Navy
            msg = "By using NEOS via SolverStudio you agree to the NEOS-Server terms and conditions, and accept that your model will become publicly available.\n\n"
            msg += "Some solvers require an email address, which you can set using the GAMS menu. "
            email = SolverStudio.GetRegistrySetting("NEOS", "Email", "")
            if email == "":
                msg += "You have not provided an email address, and so some solvers may fail."
            else:
                msg += "Your email address (" + email + ") will be sent to NEOS."
            # msg += "\n\nContinue?"
            self.link1.Text = msg
            self.link1.LinkArea = LinkArea(60, 20)

            self.AcceptButton = self.myOK
            self.CancelButton = self.myCancel

            self.Controls.Add(self.myOK)
            self.Controls.Add(self.myCancel)
            self.Controls.Add(self.link1)
            # self.Controls.Add(self.Warning)
            self.Controls.Add(self.check1)
            # self.CenterToScreen()
            self.StartPosition = FormStartPosition.CenterParent
Esempio n. 3
0
	def __init__(self):
		self.Text = "SolverStudio"
		self.FormBorderStyle = FormBorderStyle.FixedDialog    
		self.Height=150
		self.Width = 400
		self.label1 = Label()
		self.label1.Text = "Python is not installed by default in SolverStudio. You should install it yourself using one of the following links."
		self.label1.Location = Point(10,10)
		self.label1.Height  = 30
		self.label1.Width = 380
		self.myOK=Button()
		self.myOK.Text = "OK"
		self.myOK.Location = Point(310,90)
		self.myOK.Click += self.CloseForm	
		self.link1 = LinkLabel()
		self.link1.Location = Point(10, 50)
		self.link1.Width = 380
		self.link1.Height = 20
		self.link1.LinkClicked += OpenCPythonDownload
		self.link1.VisitedLinkColor = Color.Blue;
		self.link1.LinkBehavior = LinkBehavior.HoverUnderline;
		self.link1.LinkColor = Color.Navy;
		self.link1.Text = 'CPython: www.python.org/getit/'
		self.link1.LinkArea = LinkArea(9,21)
		self.link2 = LinkLabel()
		self.link2.Location = Point(10, 70)
		self.link2.Width = 380
		self.link2.Height = 40
		self.link2.LinkClicked += OpenActivePythonDownload
		self.link2.VisitedLinkColor = Color.Blue;
		self.link2.LinkBehavior = LinkBehavior.HoverUnderline;
		self.link2.LinkColor = Color.Navy;
		self.link2.Text = 'ActivePython: www.activestate.com/activepython/downloads/'
		self.link2.LinkArea = LinkArea(14,43)
		self.AcceptButton = self.myOK
		self.Controls.Add(self.myOK)		
		self.Controls.Add(self.link1)		
		self.Controls.Add(self.link2)		
		self.Controls.Add(self.label1)
		self.CenterToScreen()
Esempio n. 4
0
	def __init__(self):
		self.Text = "SolverStudio NEOS Email Address"
		self.FormBorderStyle = FormBorderStyle.FixedDialog    
		self.Height= 140
		self.Width = 460

		self.label = Label()
		self.label.Text = "Some commercial solvers on NEOS, such as CPLEX, require a valid email address. Please enter the Email address, if any, you wish to send to NEOS when you solve:"
		self.label.Location = Point(10,10)
		self.label.Height  = 35
		self.label.Width = 430

		self.KeyText = TextBox()
		self.KeyText.Location = Point(10,46)
		self.KeyText.Width = 430
		self.KeyText.Height  = 20
		self.KeyText.Text = SolverStudio.GetRegistrySetting("NEOS","Email","")
		self.KeyText.AcceptsReturn = False;

		self.bOK=Button()
		self.bOK.Text = "OK"
		self.bOK.Location = Point(270,76)
		# self.bOK.Width = 100
		self.bOK.Click += self.SetEmail

		self.link1 = LinkLabel()
		self.link1.Location = Point(10, 78)
		self.link1.Width = 250
		self.link1.Height = 40
		self.link1.LinkClicked += self.OpenTCs
		self.link1.VisitedLinkColor = Color.Blue;
		self.link1.LinkBehavior = LinkBehavior.HoverUnderline;
		self.link1.LinkColor = Color.Navy;
		self.link1.Text = "View NEOS terms and conditions"
		self.link1.LinkArea = LinkArea(5,25)

		self.bCancel=Button()
		self.bCancel.Text = "Cancel"
		self.bCancel.Location = Point(363,76)

		self.AcceptButton = self.bOK
		self.CancelButton = self.bCancel

		self.Controls.Add(self.label)
		self.Controls.Add(self.KeyText)	# Add first to get focus
		self.Controls.Add(self.link1)
		self.Controls.Add(self.bOK)
		self.Controls.Add(self.bCancel)
		self.CenterToScreen()
    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 __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 __build_label(self):
        ''' 
      Builds and return the label for the cover image.
      '''

        label = LinkLabel()
        label.UseMnemonic = False
        label.Visible = self.__config.show_covers_b
        label.Location = Point(18, 326)
        label.Size = Size(155, 36)
        label.TextAlign = ContentAlignment.MiddleCenter

        def link_clicked(sender, args):
            if self.__link_callback:
                self.__link_callback()

        label.LinkClicked += link_clicked

        return label
Esempio n. 8
0
	def __init__(self):
		self.Text = "SolverStudio"
		self.FormBorderStyle = FormBorderStyle.FixedDialog    
		self.Height=150
		self.Width = 400
		self.Warning = Label()
		self.Warning.Text = "Note: Models solved using via NEOS will be available in the public domain for perpetuity."
		self.Warning.Location = Point(10,10)
		self.Warning.Height  = 30
		self.Warning.Width = 380
		self.myOK=Button()
		self.myOK.Text = "OK"
		self.myOK.Location = Point(310,90)
		self.myOK.Click += self.AddChoice
	
		self.check1 = CheckBox()
		self.check1.Text = "Don't show this message again"
		self.check1.Location = Point(10, 80)
		self.check1.Width = 250
		self.check1.Height = 50
		
		self.link1 = LinkLabel()
		self.link1.Location = Point(10, 50)
		self.link1.Width = 380
		self.link1.Height = 40
		self.link1.LinkClicked += self.OpenTCs
		self.link1.VisitedLinkColor = Color.Blue;
		self.link1.LinkBehavior = LinkBehavior.HoverUnderline;
		self.link1.LinkColor = Color.Navy;
		self.link1.Text = "By using NEOS via SolverStudio you also agree to the NEOS-Server terms and conditions."
		self.link1.LinkArea = LinkArea(65,20)
		
		self.AcceptButton = self.myOK
		
		self.Controls.Add(self.myOK)		
		self.Controls.Add(self.link1)		
		self.Controls.Add(self.Warning)	
		self.Controls.Add(self.check1)

		self.CenterToScreen()
   def __build_label(self):
      ''' 
      Builds and return the label for the cover image.
      '''
      
      label = LinkLabel()
      label.UseMnemonic = False
      label.Visible = self.__config.show_covers_b
      label.Location = Point(18, 326)
      label.Size = Size(155,36)
      label.TextAlign = ContentAlignment.MiddleCenter
      
      def link_clicked(sender, args):
         if self.__link_callback:
            self.__link_callback()
      label.LinkClicked += link_clicked

      return label
Esempio n. 10
0
    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)

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

        #Create a weblink
        helplink = LinkLabel()
        helplink.Text = "User Guide"
        helplink.Tag = linkaddress  #tag is the web address
        helplink.Click += self.openLink  #register click event with event handler
        helplink.Location = Point(uiWidth - ((btnOk.Width * 3) + spacing),
                                  uiHeight - (btnOk.Height + 5))
        self.Controls.Add(helplink)
        helplink.Anchor = (AnchorStyles.Bottom | AnchorStyles.Left)

        colourPanel = Panel()
        colourPanel.Height = cBox.Height + spacing  #locate the panel behind the combo box.
        colourPanel.Width = uiWidth
        colourPanel.Location = Point(0, (uiHeight / 3) - 5)
        colourPanel.BorderStyle = BorderStyle.Fixed3D  # graphical style to pronounce the edge of the panel
        colourPanel.BackColor = Color.FromArgb(
            1, 125, 199)  #set background colour by RGB value
        self.Controls.Add(colourPanel)