Beispiel #1
0
def runInGUI():

    clr.AddReference('System.Windows.Forms')
    clr.AddReference('System.Drawing')
    from System.Windows.Forms import Application
    #     global oDesktop
    import MainForm
    Application.EnableVisualStyles()
    form = MainForm.MainForm()
    form.Text = MainForm.titleWin
    Application.Run(form)
    form.Dispose()
Beispiel #2
0
def DispatchConsoleCommand(consoleCommand):
    if consoleCommand:
        # consoleCommand is a delegate for a dynamic method that embodies the
        # input expression from the user.  Run it on the other thread.
        dispatcher.Invoke(consoleCommand)
    else:
        Application.Exit()
Beispiel #3
0
def main():
    FLExInit.Initialize()

    form = FTMainForm()
    Application.Run(form)

    FLExInit.Cleanup()
Beispiel #4
0
def renameROI(ROIname, plan, case):
	Popup = SelectROIForm(plan)
	Popup.redefine_text('Select the roi that is %s' %ROIname)
	Application.Run(Popup)

	with CompositeAction('Apply ROI changes (%s)' %Popup.roi_name_list[0]):
		case.PatientModelRegionsOfInterest['%s' %Popup.roi_name_list[0]].Name = ROIname
def message_window(input = "Everything's fine"):

    class DebugWindow(Form):
        def __init__(self):
            self.Text = "Message"

            self.Width = 750
            self.Height = 850

            self.setupMessageWindow()
            self.setupOKButtons()

            self.Controls.Add(self.MessageWindow)
            self.Controls.Add(self.OKbuttonPanel)
            
        def bigPanel(self, x, y):
            panel = Panel()
            panel.Width = 750
            panel.Height = 700
            panel.Location = Point(x, y)
            panel.BorderStyle = BorderStyle.None
            return panel

        def miniPanel(self, x, y):
            panel = Panel()
            panel.Width = 750
            panel.Height = 150
            panel.Location = Point(x, y)
            panel.BorderStyle = BorderStyle.None
            return panel                           
            
        def setupMessageWindow(self):
            self.MessageWindow = self.bigPanel(0, 0)

            self.Label1 = Label()
            self.Label1.Text = input
            self.Label1.Location = Point(25, 25)
            self.Label1.Font = Font("Arial", 10)
            self.Label1.AutoSize = True
            
            self.MessageWindow.Controls.Add(self.Label1)

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

        def setupOKButtons(self):
            self.OKbuttonPanel = self.miniPanel(0, 750)
            
            cancelButton = Button()
            cancelButton.Text = "Cancel"
            cancelButton.Location = Point(25,25)
            self.CancelButton = cancelButton
            cancelButton.Click += self.cancelClicked

            self.OKbuttonPanel.Controls.Add(cancelButton)


    form = DebugWindow()
    Application.Run(form)   
 def __enter__(self):
     self.onChange = ProgressBarUtils.EventHook()
     Application.EnableVisualStyles()
     f = ProgressBarUtils.ProgressBarDialog(self,
                                            self._number_Iteration,
                                            self._title)
     f.Show()
     return self
 def on_click(self, sender, event):
     if sender == self.menuitem2 or sender == self.menuitem3:
         sender.Checked = not sender.Checked
         status = sender.Checked and ' ' or ' not '
         self.label.Text = "%s is%schecked" % (sender.Text, status)
     elif sender == self.menuitem4:
         Application.Exit()
     else:
         self.label.Text = "you have clicked %s" % sender.Text
Beispiel #8
0
 def on_click(self, sender, evernt):
     if sender == self.menu_file_exit:
         Application.Exit()
     elif sender == self.menu_help_about:
         MessageBox.Show("Mono:Accessibility winform controls test sample\n"
                         "Developer: Novell a11y hackers",
                         "About")
     else:
         self.label.Text = "You have clicked %s" % sender.Text
Beispiel #9
0
def thread_proc():
    try:
        global dispatcher
        global are
        # Create a dummy Control so that we can use it to dispatch commands to the WinForms thread
        dispatcher = Form(Size=Size(0, 0))
        dispatcher.Show()
        dispatcher.Hide()
        are.Set()
        Application.Run()
    finally:
        IronPython.Hosting.PythonEngine.ConsoleCommandDispatcher = None
 def myFunction(self):
     if self._progressBar1.Value < self._progressBar1.Maximum:
         self._progressBar1.Value += 1
         self._label1.Text = "Items Processing {}/{}".format(
             str(self._progressBar1.Value), str(self._numberLines))
         try:
             Application.DoEvents()
         except:
             pass
     else:
         self._theBroadcaster.onChange -= self.myFunction
         self.Close()
Beispiel #11
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...')
Beispiel #12
0
def create_form():
    f = Form()
    f.Text = "HelloIronPython"

    btn = Button()
    btn.Text = "ClickMe"

    f.Controls.Add(btn)

    btn.Top = (f.ClientSize.Height - btn.Height) / 2
    btn.Left = (f.ClientSize.Width - btn.Width) / 2

    Application.Run(f)
Beispiel #13
0
 def shower():                                                           
    with cls(*args) as form:
       Monitor.Enter(cls)
       try:
          cls.newform = form
          Monitor.Pulse(cls)
       finally:
          Monitor.Exit(cls)
       def exception_handler(sender, event):
          log.handle_error(event.Exception)  
       Application.ThreadException +=\
          ThreadExceptionEventHandler(exception_handler)
       Application.Run(form) # start form on new App thread; blocks
Beispiel #14
0
def thread_proc():
    try:
        global dispatcher
        global are
        # Create the dummy control, and show then hide it to get Windows Forms
        # to initialize it.
        dispatcher = Form(Size=Size(0, 0))
        dispatcher.Show()
        dispatcher.Hide()
        # Signal that the thread running thread_proc is ready for the main
        # thread to send input to it.
        are.Set()
        # Start the message loop.
        Application.Run()
    finally:
        # In case thread_proc's thread dies, restore the default IronPython
        # console execution behavior.
        clr.SetCommandDispatcher(None)
Beispiel #15
0
    def __init__(self):

        c = Form()

        def attached(source, args):
            print('my_handler called!')

        def detached(source, args):
            print('Detatched')

        a = clr.UsbFsm100ServerClass(c.Handle)

        a.Attached += attached
        a.Detached += detached
        self.usb = a

        Application.Run(c)

        self.threshold = 10000.
Beispiel #16
0
    def __init__(self):
        
        c = Form()
        self.connected = False
        def attached(source, args):
            print('Connected to splicer')
            self.connected = True
        def detached(source,args):
            self.connected = False
            print('Disconnected from splicer')

        a = clr.UsbFsm100ServerClass(c.Handle  )

        
        a.Attached += attached
        a.Detached += detached
        self.usb = a      
        self.c = c
        #c.Visible=False
        #c.Show()
        #c.Close()
        Application.DoEvents()  #<--- BOO YA
        #Application.Run(c)  
        print('g')
        #c.Close()
        #a.close()
        
        self.usb.Clear()
        self.threshold = 2000.
        
        self.lastZLZR = ('0','0')
        self.lastarc  = 0,0
        
        
        self.lastmove    = self.readZLZR()
        self.lastvelocity = (0.,0.) #important for moving fast
        self.lastZLZR = self.readZLZR()
        self.lastarc = (0,0)
        
        self.immodeSize = {1:np.array((640,480)),2:np.array((640,480)),3:np.array((486,364))}
        self.exposure = 0.
Beispiel #17
0
    def LoadRss(self):
        """
		Caches the rss feeds so they don't have to be redownloaded over and over again
		"""
        for rss in self.imageRssList:
            if rss not in self.rssCache:
                #TODO replace download with comicracks download functions
                Application.DoEvents()
                #print "rss does not exist, fetching"
                try:
                    imgXml = XmlDocument()
                    imgXml.Load(rss)

                    #Load the wanted items
                    imgItems = imgXml.SelectNodes("rss/channel/item")
                    self.rssCache[rss] = imgItems

                except Exception, ex:
                    # MessageBox.Show("Something went wrong accessing the images rss feed. Are you connected to the internet?")
                    # print str(ex)
                    # Now disabled as a result of
                    return False
Beispiel #18
0
	def buttonPressed(self, sender, args):
		global currentDir, pathContactFile, pathCallRecordsFile
		currentDir = sender.FindForm().Controls.Find('ImportDir',True)[0].Text
		#fileNameRegex = sender.FindForm().Controls.Find('fileNameRegex',True)[0].Text
		try:
			startTime = time.time()
			#currentDir= __file__[:__file__.rfind('\\')]+"\\EmailWhatsApp\\"
			#debugFile = currentDir+"/log.txt"
			pathContactFile = currentDir+'/contactsRecords.dat'
			pathCallRecordsFile = currentDir+'/callsRecords.dat'
			#calling the parser for results
			results = SPIWhatsAppEmailsParser().parse()
			print "Finished",('The script took {0} seconds !'.format(time.time() - startTime))
			Application.Exit()
		except Exception as e:
			print traceback.format_exc()
			exc_type, exc_obj, exc_tb = sys.exc_info()
			fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
			print(exc_type, fname, exc_tb.tb_lineno)
			print("Oops!", sys.exc_info(), "occurred.")
			print('ERRO: Error importing whatsapp data.')
			return
Beispiel #19
0
    def draw(self, show=True, filename=None, update=False, usecoords=False):
        """Create a 2D depiction of the molecule.

        Optional parameters:
          show -- display on screen (default is True)
          filename -- write to file (default is None)
          update -- update the coordinates of the atoms to those
                    determined by the structure diagram generator
                    (default is False)
          usecoords -- don't calculate 2D coordinates, just use
                       the current coordinates (default is False)

        Tkinter and Python Imaging Library are required for image display.
        """
        obconversion = ob.OBConversion()
        formatok = obconversion.SetOutFormat("_png2")
        if not formatok:
            raise ImportError("PNG depiction support not found. You should "
                              "compile Open Babel with support for Cairo. See "
                              "installation instructions for more "
                              "information.")

        # Need to copy to avoid removing hydrogens from self
        workingmol = Molecule(ob.OBMol(self.OBMol))
        workingmol.removeh()

        if not usecoords:
            _operations['gen2D'].Do(workingmol.OBMol)
        if update:
            if workingmol.OBMol.NumAtoms() != self.OBMol.NumAtoms():
                raise RuntimeError("It is not possible to update the original "
                                   "molecule with the calculated coordinates, "
                                   "as the original molecule contains "
                                   "explicit hydrogens for which no "
                                   "coordinates have been calculated.")
            else:
                for i in range(workingmol.OBMol.NumAtoms()):
                    self.OBMol.GetAtom(i + 1).SetVector(
                        workingmol.OBMol.GetAtom(i + 1).GetVector())
        if filename:
            filedes = None
        else:
            if sys.platform[:3] == "cli" and show:
                raise RuntimeError("It is only possible to show the molecule "
                                   "if you provide a filename. The reason for "
                                   "this is that I kept having problems "
                                   "when using temporary files.")

            filedes, filename = tempfile.mkstemp()

        workingmol.write("_png2", filename=filename, overwrite=True)

        if show:
            if sys.platform[:4] == "java":
                image = javax.imageio.ImageIO.read(java.io.File(filename))
                frame = javax.swing.JFrame(visible=1)
                frame.getContentPane().add(
                    javax.swing.JLabel(javax.swing.ImageIcon(image)))
                frame.setSize(300, 300)
                frame.setDefaultCloseOperation(
                    javax.swing.WindowConstants.DISPOSE_ON_CLOSE)
                frame.show()
            elif sys.platform[:3] == "cli":
                form = _MyForm()
                form.setup(filename, self.title)
                Application.Run(form)
            else:
                if not tk:
                    raise ImportError("Tkinter or Python Imaging Library not "
                                      "found, but is required for image "
                                      "display. See installation instructions "
                                      "for more information.")
                root = tk.Tk()
                root.title((hasattr(self, "title") and self.title)
                           or self.__str__().rstrip())
                frame = tk.Frame(root, colormap="new",
                                 visual='truecolor').pack()
                image = PIL.open(filename)
                imagedata = piltk.PhotoImage(image)
                tk.Label(frame, image=imagedata).pack()
                tk.Button(root, text="Close",
                          command=root.destroy).pack(fill=tk.X)
                root.mainloop()
        if filedes:
            os.close(filedes)
            os.remove(filename)
class HelloWorldForm(Form):
    def __init__(self):
        self.Text = 'Hello World'

        self.label = Label()
        self.label.Text = "Please Click Me"
        self.label.Location = Point(50, 50)
        self.label.Height = 30
        self.label.Width = 200

        self.count = 0

        button = Button()
        button.Text = "Click Me"
        button.Location = Point(50, 100)

        button.Click += self.buttonPressed

        self.Controls.Add(self.label)
        self.Controls.Add(button)

    def buttonPressed(self, sender, args):
        print 'The label *used to say* : %s' % self.label.Text
        self.count += 1
        self.label.Text = "You have clicked me %s times." % self.count


form = HelloWorldForm()
Application.Run(form)
Beispiel #21
0
    def Parse(self, entry):
        #print "Starting to parse entry"
        #print entry
        titlename = re.search("\d*/\d*/\d*", entry.title).group(0)
        #print "Name of entry title is: "
        #print titlename
        if not self.ComicList.Tables.Contains(titlename):
            #print "Table is not yet in dataset"
            Application.DoEvents()

            #print "Creating row for WeekList but do not add it yet as it still needs the publisherlist"
            row2 = self.ComicList.Tables["WeekList"].NewRow()
            #print "Created new row in weeklist"

            row2["Date"] = titlename

            publisherlist = []

            #print "Create the datatable for the list of comics"
            data = DataTable(titlename)
            id = DataColumn("ID")
            pub = DataColumn("Publisher")
            title = DataColumn("Title")
            price = DataColumn("Price")
            image = DataColumn("Image")
            image.DataType = System.Type.GetType('System.String')
            id.DataType = System.Type.GetType('System.Int32')
            pub.DataType = System.Type.GetType('System.String')
            title.DataType = System.Type.GetType('System.String')
            price.DataType = System.Type.GetType('System.String')
            data.Columns.Add(id)
            data.Columns.Add(pub)
            data.Columns.Add(title)
            data.Columns.Add(price)
            data.Columns.Add(image)
            #print "Finished Creating data columns"

            #print "Now finding the list of comics"
            x = HtmlAgilityPack.HtmlDocument()
            x.LoadHtml(entry.content)
            nodes = x.DocumentNode.SelectNodes("pre")
            #Find the largest paragraph in the source.
            #The largest paragraph contains the comiclist
            index = {"index": 0, "length": 0}
            comiclistNode = None
            for node in nodes:
                if comiclistNode is None or len(node.InnerText) > len(
                        comiclistNode.InnerText):
                    comiclistNode = node
                Application.DoEvents()

            if comiclistNode is None:
                print "No comic list found"
                return None, None
            #Now that we know which node the comiclist is, parse it into a csv list
            try:
                comiclist = HtmlEntity.DeEntitize(nodes[0].InnerHtml).replace(
                    '<br>', '\n').splitlines()
            except Exception, ex:
                print ex
                print "Something failed"
                return None, None

            #Don't need these
            del (x)
            del (nodes)

            # print comiclist

            count = 1
            #Go through all the lines in the list execpt the first one which is the definitions.
            for line in comiclist[1:]:
                try:
                    #print count
                    print line
                    Application.DoEvents()
                    #Using python list doesn't work, so use System.Array
                    l = System.Array[str](line.strip().replace('"',
                                                               '').split(','))
                    row = data.NewRow()

                    date, code, publisher, title, price = l

                    row["ID"] = count
                    count += 1
                    row["Publisher"] = publisher

                    if not publisher in publisherlist and not publisher in self.BlackList:
                        publisherlist.append(publisher)
                    row["Title"] = title
                    if price:
                        row["Price"] = price
                    else:
                        row["Price"] = ""
                    row["Image"] = ""
                    data.Rows.Add(row)
                except Exception, ex:
                    #Line was not formated in the normal pattern
                    #print ex
                    #print type(ex)
                    #print line
                    continue
Beispiel #22
0
clr.AddReference("System.Windows.Forms")
clr.AddReference("System.Drawing")

from System.Windows.Forms import Application, Form, Button
from System.Drawing import Size, Point


class IForm(Form):
    def __init__(self):
        self.Text = "Button"
        self.CenterToScreen()
        self.Size = Size(200, 150)

        btn = Button()
        btn.Parent = self
        btn.Text = "Quit"
        btn.Location = Point(50, 50)
        btn.Click += self.OnClick
        btn.MouseEnter += self.OnEnter

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

    def OnEnter(self, sender, args):
        print "Button Entered"


if __name__ == "__main__":
    Application.Run(IForm())
 def onExit(self, sender, event):
     self.notifyIcon.Visible = False
     Application.Exit()
    def __init__(self):
        self.initNotifyIcon()
        self.showBalloon("Saving...", "Your DVD is being archived")

    def initNotifyIcon(self):
        self.notifyIcon = NotifyIcon()
        self.notifyIcon.Icon = Icon("dvd.ico")
        self.notifyIcon.Visible = True
        self.notifyIcon.ContextMenu = self.initContextMenu()

    def showBalloon(self, title, text, duration=1000):
        self.notifyIcon.BalloonTipTitle = title
        self.notifyIcon.BalloonTipText = text
        self.notifyIcon.ShowBalloonTip(duration)

    def initContextMenu(self):
        contextMenu = ContextMenu()
        exitMenuItem = MenuItem("Exit")
        exitMenuItem.Click += self.onExit
        contextMenu.MenuItems.Add(exitMenuItem)
        return contextMenu

    def onExit(self, sender, event):
        self.notifyIcon.Visible = False
        Application.Exit()


if __name__ == "__main__":
    main = Notification()
    Application.Run()
Beispiel #25
0
def main():
    form = IForm()
    Application.Run(form)
Beispiel #26
0
clr.AddReference('System.Windows.Forms')
clr.AddReference('System.Drawing')
from System.Windows.Forms import (
    Application, Form,
    FormBorderStyle, Label
)
from System.Drawing import (
    Color, Font, FontStyle, Point
)

class MainForm(Form):
    def __init__(self):
        self.Text = "Hello World"
        self.FormBorderStyle = FormBorderStyle.Fixed3D
        self.Height = 150
        
        newFont = Font("Verdana", 16, FontStyle.Bold | FontStyle.Italic)

        label = Label()
        label.AutoSize = True
        label.Text = "My Hello World Label"
        label.Location = Point(10, 50)
        label.BackColor = Color.Aquamarine
        label.ForeColor = Color.DarkMagenta
        label.Font = newFont

        self.Controls.Add(label)

mainForm = MainForm()
Application.Run(mainForm)
#############-------------\-------------#############
        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

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

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


ddForm = DropDownForm()

if run:     #if input is true run the application.
    Application.Run(ddForm)






    
    
Beispiel #28
0
import clr

clr.AddReference('System.Windows.Forms')
clr.AddReference('System.Drawing')

from System.Windows.Forms import Application
import MainForm

Application.EnableVisualStyles()
form = MainForm.MainForm()
Application.Run(form)
            return 'Britain'
        elif 2100 <= x < 2690 and 1280 <= y < 2030:
            return 'Cove'
        elif 1385 <= x < 2690 and 2030 <= y < 3075:
            return 'Trinsic'
        elif 1900 <= x < 2690 and 3075 <= y <= 4096:
            return 'Valor'
        elif 2580 <= x < 3250 and y < 1890:
            return 'Vesper'
        elif 3250 <= x < 4100 and y < 1890:
            return "Nujel'm"
        elif 2100 <= x < 3850 and 1890 <= y < 3075:
            return 'Bucca'
        elif 2690 <= x < 3850 and 3075 <= y <= 4096:
            return 'Fire'
        elif x >= 4100 and y < 1890:
            return 'Moonglow'
        elif x >= 3850 and 1890 <= y < 2890:
            return 'Sea Market'
        elif x >= 3850 and y >= 2890:
            return 'Hythloth'
        else:
            return 'None'


Misc.SendMessage('Select the SOS container.', 67)
sbag = Target.PromptTarget()
if sbag > -1:
    SH = SOSManager(sbag)
    Application.Run(SH)
Beispiel #30
0
                self.m_req.Update -= self.m_req_Update
                self.m_req.Dispose()
                self.m_req = None
            if (self.m_ps != None):
                self.m_ps.FieldsUpdated -= self.m_ps_FieldsUpdated
                self.m_ps.Dispose()
                self.m_ps = None
        #Begin shutdown the TT API
        ttapi.TTAPI.ShutdownCompleted += self.TTAPI_ShutdownCompleted
        ttapi.TTAPI.Shutdown()
        self.m_disposed = True

# Unattached callbacks and dispose of all subscriptions
# Begin shutdown the TT API

    def TTAPI_ShutdownCompleted(self, sender, e):
        """ <summary>
		 Event notification for completion of TT API shutdown
		 </summary>
        """
        # Shutdown the Dispatcher
        if self.m_disp != None:
            self.m_disp.BeginInvokeShutdown()
            self.m_disp = None

with ttapi.Dispatcher.AttachUIDispatcher() as disp:
    tr = TTAPIReadForm()
    m_handler = ttapi.ApiInitializeHandler(tr.ttApiInitHandler)
    ttapi.TTAPI.CreateXTraderModeTTAPI(disp, m_handler)
    Application.Run(tr)