Esempio n. 1
0
 def idle_func():
     gtk.threads_enter()
     try:
         function(*args, **kw)
         return False
     finally:
         gtk.threads_leave()
Esempio n. 2
0
def roscb(data):
    global sc1
    global sc2
    global sc3
    global sc4
    global sc5
    global sc6
    global testv
    matrices = data.tactile_matrix
    gtk.threads_enter()
    for mat in matrices:
        if(mat.matrix_id == 0):
            sc1.setMatrixSize(mat.cells_x,mat.cells_y)
            sc1.updateTactileMatrix(mat.tactile_array)
        if(mat.matrix_id == 1):
            sc2.setMatrixSize(mat.cells_x,mat.cells_y)
            sc2.updateTactileMatrix(mat.tactile_array)
        if(mat.matrix_id == 2):
            sc3.setMatrixSize(mat.cells_x,mat.cells_y)
            sc3.updateTactileMatrix(mat.tactile_array)
        if(mat.matrix_id == 3):
            sc4.setMatrixSize(mat.cells_x,mat.cells_y)
            sc4.updateTactileMatrix(mat.tactile_array)
        if(mat.matrix_id == 4):
            sc5.setMatrixSize(mat.cells_x,mat.cells_y)
            sc5.updateTactileMatrix(mat.tactile_array)
        if(mat.matrix_id == 5):
            sc6.setMatrixSize(mat.cells_x,mat.cells_y)
            sc6.updateTactileMatrix(mat.tactile_array)
    gtk.threads_leave()
Esempio n. 3
0
def gui_report(opts):
    gobject.idle_add(GuiReport(opts).start)
    gtk.threads_enter()
    gtk.main()
    gtk.threads_leave()
    
    
Esempio n. 4
0
        def callback():
            completion_result = \
                self.work_queue.work_request_completed(request_id)

            if completion_result is not None:
                gtk.threads_enter()  # This is not a GTK+ callback
                self.reset_progress()
                (result_code, result_details) = completion_result

                ## If result_code is "", it means everything is OK.
                if result_code == "":
                    message = "<b>%s</b> completed successfully" % script_name
                    self.status_display(message, has_markup=True)
                    self.log_display(message, has_markup=True)

                else:
                    status_msg = "<b>%s</b> terminated due to errors" % script_name
                    self.status_display(status_msg, has_markup=True)
                    message = ('A fatal error of kind "%s" was encountered during ' +\
                               'execution of script "%s".') % (result_code, script_name)
                    details = "Details:\n" + result_details
                    self.log_display(message + "\n" + details,
                                     has_markup=False)
                    MessageBox(message, details, type=gtk.MESSAGE_ERROR)

                ## Done: don't call again, and add a new tab corresponding
                ## to the expdir.  Check for expdir existence first, since
                ## some experiments don't necessarily leave an expdir around
                if os.path.isdir(self.work_requests[request_id]):
                    self.add_intelligent_tab(self.work_requests[request_id])
                gtk.threads_leave()
                return False
            else:
                ## Call again later
                return True
Esempio n. 5
0
 def set_sample_value(self, value="", channel=0):
     """ Write a sample value to the textbox. """
     gtk.threads_enter()
     self.values[channel] = value
     self.update_string_for_textbox()
     gtk.threads_leave()
     return
Esempio n. 6
0
 def updateStartProcess(self):
     if self.threadNotifyType == 1:
         gtk.threads_enter()
         self.progressDialog.progressStarted()
         gtk.threads_leave()
     else:
         glib.idle_add(self.progressDialog.progressStarted)
Esempio n. 7
0
 def updateFinishProgress(self):
     if self.threadNotifyType == 1:
         gtk.threads_enter()
         self.progressDialog.progressDone()
         gtk.threads_leave()
     else:
         glib.idle_add(self.progressDialog.progressDone)
Esempio n. 8
0
	def run(self):
		global menu_items
		global st
		
		while not st.stopthread.isSet() :
			gtk.threads_enter()
			finish = datetime.datetime.now()
			delta = finish - start
			t = "Syncing %s" % (delta)
			menu_items.set_label(t)
			gtk.threads_leave()
			
			time.sleep(0.1)

		if st.stopthread.isSet() :
			a = "%s/NeedRepoScript" % (configdir)
			b = "%s/NoDeviceC" % (configdir)
			c = "%s/GenError" % (configdir)
			if os.path.exists(a):
				ind.set_icon(cmcIntE)
				menu_items.set_label("Repo Script needs setup")
			elif os.path.exists(b):
				ind.set_icon(cmcIntE)
				menu_items.set_label("No device configured!")
			elif os.path.exists(b):
				ind.set_icon(cmcIntE)
				menu_items.set_label("General sync error. Run in terminal")
			else:
				menu_items.set_label("Complete!")
				sendNoti("Syncing Complete", "Your cyanogenmod repo is finished syncing!", cmcIcon)
Esempio n. 9
0
    def run(self):
        global remaining
        
        try:
            local = os.path.basename(self.url)
            if not local: local = 'index.html'
            opener.retrieve(self.url, local, reporthook=self.download_status)
        except SystemExit:
            pass
        except:
            traceback.print_exc()

        # if we completed the download, now clean things up.
        gtk.threads_enter()

        self.frame.destroy()
        del self.progress, self.frame

        remaining_lock.acquire()
        remaining -= 1
        value = remaining
        remaining_lock.release()

        if value == 0:
            gtk.main_quit()

        gtk.threads_leave()
Esempio n. 10
0
	def generateGcode_Thread(self, gcodeFilename, tolerance):
		
		generateGcode(self.segmentGroups, gcodeFilename, tolerance)
		
		gtk.threads_enter()
		self.indicateLoading(False)
		gtk.threads_leave()
Esempio n. 11
0
    def run(self):  # function to play the xml file
        beatlist = make_beat_list(self.duration, self.beats)
        while self.position in range(len(beatlist)):
            self.playing.wait()
            if self.stopthread.isSet():
                break
            i = self.position
            self.m_number_control.set_text(
                str(
                    int((float(i) - beatlist[:20].index(self.pickup_beat)) / (len(self.beats) * self.beats_per_measure))
                    + 1
                )
            )  # stupid type system...

            gtk.threads_enter()
            # find the notes that are to be turned on and off at this beat
            noteOnList = self.sheet.findall(".//playingfrom[@start='" + str(beatlist[i]) + "']/..")
            noteOffList = self.sheet.findall(".//playingfrom[@end='" + str(beatlist[i]) + "']/..")
            self.tempo = self.tempoChanges.get(beatlist[i], self.tempo)

            self.pianoObj.ext_note_release(map((lambda x: noteToValue(x.get("value"))), noteOffList))
            gtk.threads_leave()
            time.sleep(0.05)  # time delay to make keys flash for repeat notes
            if self.stopthread.isSet():
                break
            gtk.threads_enter()
            self.pianoObj.ext_note_press(map((lambda x: noteToValue(x.get("value"))), noteOnList))

            gtk.threads_leave()
            self.position += 1
            if i < len(beatlist) - 1:
                time.sleep(60 * (beatlist[i + 1] - beatlist[i]) / self.tempo - 0.05)
Esempio n. 12
0
    def main(self):
        gtk.threads_enter()

        # Splash
        splash = gtk.Window()
        splash.set_decorated(False)
        splash.set_position(gtk.WIN_POS_CENTER)

        # VBox
        vbox = gtk.VBox(homogeneous=False, spacing=0)
        vbox.show()
        splash.add(vbox)

        # Background
        background = gtk.Image()
        background.set_from_file(self.ini.get(self.profile, 'BACKGROUND'))
        background.show()
        vbox.pack_start(background, expand=True, fill=True, padding=0)

        # ProgressBar
        progressbar = gtk.ProgressBar()
        progressbar.show()
        progressbar.set_text('Please Wait')
        vbox.pack_end(progressbar, expand=True, fill=True, padding=0)

        splash.show()
        while gtk.events_pending():
            gtk.main_iteration()
        self.setup(progressbar)
        #		splash.hide()
        splash.destroy()

        gtk.main()
        gtk.threads_leave()
	def performe_check(self):
		out = self.output
		
		url = self.inputAddress.get_text()

		gtk.threads_enter()	
		output = out.get_buffer()
		output.set_text(output.get_text(output.get_start_iter(), output.get_end_iter())+"\nChecking "+url+"...\n")
		out.set_buffer(output)
		gtk.threads_leave()
		
		check = Check()
		r = check.check(url)
		o = ""
		
		if r[0] == -1:
			o = "Error: "+url+" not found"

		elif r[0] == -2:
			o =  "error querying remote server.\nerror code :" + r[1] + "\nerror message: "+ r[2]

		elif r[0] == 0:
			o =  url + " resolves LOCAL to " + r[1] +"\n"+ url + " resolves REMOTE to " + r[2] + "\nthis could be a pharming attac or a location-based dns"
			
		elif r[0] == 1:
			o = "No differences found!\n" + url + " resolves to " + self.explode(r[2])
		
		gtk.threads_enter()
		output = out.get_buffer()
		output.set_text(output.get_text(output.get_start_iter(), output.get_end_iter())+"\n"+o+"\n---\n")
		out.set_buffer(output)
		gtk.threads_leave()
    def run (self):
        global window
        global image
        #global img_pixmap
        #global img_mask

        self.HOST = 'localhost'
        self.PORT = 50012
        self.s = socket.socket (socket.AF_INET, socket.SOCK_STREAM)
        self.s.bind ((self.HOST, self.PORT))
        self.s.listen (1)

        while not self.stop_socket.isSet ():
            conn, addr = self.s.accept ()
            gtk.threads_enter ()
            data = conn.recv (1024)
            if data == "END":
                main_quit ()
                break

            # Changing the image object to the image needed.
            file_name = os.path.join (imgs_path, data + '.jpg')
            pixbuf = gtk.gdk.pixbuf_new_from_file (file_name)
            pixmap, mask = pixbuf.render_pixmap_and_mask ()
            image.set_from_pixmap (pixmap, mask)
            #image.set_from_pixmap (img_pixmap[int (data) - 1], img_mask[int (data) - 1])

            gtk.threads_leave ()
            conn.close ()

        self.s.close ()
Esempio n. 15
0
 def __find(self):
     self.status(1, "searching")
     self.__nfound = 0
     for i, filename in enumerate(self.get_files()):
         if i % 16 == 0:
             self.status(self.__nfound)
         try:
             f = open(filename, 'r')
         except IOError:
             continue
         for linenumber, line in enumerate(f):
             if not self.__running:
                 self.__finished()
             if BINARY_RE.match(line):
                 break
             line = string.translate(line, all_chars, hi_bit_chars)
             line = string.translate(line, hi_lo_table)
             matches = self.__pattern.findall(line)
             if len(matches):
                 self.__nfound = self.__nfound + len(matches)
                 if self.__nfound >= self.__options.maxresults:
                     self.__finished()
                 result = GrepResult(linenumber, filename, line, matches)
                 gtk.threads_enter()
                 self.emit('found', result)
                 gtk.threads_leave()
         f.close()
     self.__finished()
Esempio n. 16
0
        def callback():
            completion_result = self.work_queue.work_request_completed(request_id)

            if completion_result is not None:
                gtk.threads_enter()  # This is not a GTK+ callback
                self.reset_progress()
                (result_code, result_details) = completion_result

                ## If result_code is "", it means everything is OK.
                if result_code == "":
                    message = "<b>%s</b> completed successfully" % script_name
                    self.status_display(message, has_markup=True)
                    self.log_display(message, has_markup=True)

                else:
                    status_msg = "<b>%s</b> terminated due to errors" % script_name
                    self.status_display(status_msg, has_markup=True)
                    message = ('A fatal error of kind "%s" was encountered during ' + 'execution of script "%s".') % (
                        result_code,
                        script_name,
                    )
                    details = "Details:\n" + result_details
                    self.log_display(message + "\n" + details, has_markup=False)
                    MessageBox(message, details, type=gtk.MESSAGE_ERROR)

                ## Done: don't call again, and add a new tab corresponding
                ## to the expdir.  Check for expdir existence first, since
                ## some experiments don't necessarily leave an expdir around
                if os.path.isdir(self.work_requests[request_id]):
                    self.add_intelligent_tab(self.work_requests[request_id])
                gtk.threads_leave()
                return False
            else:
                ## Call again later
                return True
Esempio n. 17
0
	def run(self):
		global sc1
		while not self.stopthread.isSet() :
			gtk.threads_enter()
			sc1.updateTactileMatrix("test")
			gtk.threads_leave()
			time.sleep(0.5)
Esempio n. 18
0
 def set_sample_value(self, value='', channel=0):
     ''' Write a sample value to the textbox. '''
     gtk.threads_enter()
     self.values[channel] = value
     self.update_string_for_textbox()
     gtk.threads_leave()
     return
Esempio n. 19
0
 def idle_func():
     gtk.threads_enter()
     try:
         function(*args, **kw)
         return False
     finally:
         gtk.threads_leave()
Esempio n. 20
0
    def joined(self, command):
        for i in range(0, len(self.lobby_channel_names)):
            if command[0] == self.lobby_channel_names[i]:
                channel_index = i

        iter = self.user_liststore.get_iter_first()
        while iter != None:
            username = self.user_liststore.get_value(iter, 0)
            if username == command[1]:
                gtk.threads_enter()
                self.lobby_channel_users[channel_index].append([
                    username,
                    self.user_liststore.get_value(iter, 1),
                    self.user_liststore.get_value(iter, 2),
                    self.user_liststore.get_value(iter, 3),
                    self.user_liststore.get_value(iter, 4),
                    self.user_liststore.get_value(iter, 5),
                    self.user_liststore.get_value(iter, 6)
                ])
                gtk.threads_leave()
                break
            iter = self.user_liststore.iter_next(iter)

        text = '* ' + command[1] + ' has joined ' + command[0]
        self.update_textbuffer_channel(command[0], None, text, "join")
Esempio n. 21
0
    def display_license_window(self, licenses):
        dialog = gtk.MessageDialog(self.parent(), 0,
                                   gtk.MESSAGE_INFO,
                                   gtk.BUTTONS_NONE,
                                   _("You must agree to the licenses "
                                     "covering this software before "
                                     "installing it."))

        license_texts = string.join(licenses, "\n" + "#"*79 + "\n")

        text = gtk.TextView()
        text.set_editable(0)
        text.set_cursor_visible(0)
        text.set_wrap_mode(gtk.WRAP_WORD)

        buf = text.get_buffer()
        buf.set_text(license_texts)

        context = text.get_pango_context()
        font_desc = context.get_font_description()
        font_desc.set_family("monospace")

        # Try to estimate the size of the window we want.
        # "W" being the widest glyph.
        s = ("W"*82 + "\n")*20
        layout = pango.Layout(context)
        layout.set_font_description(font_desc)
        layout.set_text(s)
        width, height = layout.get_pixel_size()
        text.set_size_request(width, height)

        # Create a tag with our monospace font
        tag = buf.create_tag()
        tag.set_property("font-desc", font_desc)
        buf.apply_tag(tag, buf.get_start_iter(), buf.get_end_iter())

        # Get a mark to the start of the buffer and then scroll there
        iter = buf.get_start_iter()
        mark = buf.create_mark("start", iter, left_gravity=1)
        text.scroll_to_mark(mark, 0.0)

        sw = gtk.ScrolledWindow()
        sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        sw.set_shadow_type(gtk.SHADOW_IN)
        sw.add(text)
        sw.show_all()
        dialog.vbox.pack_start(sw, expand=1, fill=1)

        dialog.add_button(_("I Agree"), gtk.RESPONSE_OK)
        dialog.add_button(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)

        gtk.threads_enter()
        response = dialog.run()
        dialog.destroy()
        gtk.threads_leave()
        if response != gtk.RESPONSE_OK:
            self.pop()
            return 0

        return 1
Esempio n. 22
0
 def reg_textview(self, actor, text):
     gtk.threads_enter()
     textview = gtk.TextView()
     textview.get_buffer().set_text(text)
     textview.get_buffer().connect("changed", self.ext_view_changed, actor)
     gtk.threads_leave()
     self.widgets[actor] = textview
Esempio n. 23
0
    def run(self):
        start_method = None
        print "Start: ", self.start_simulation_method
        if self.start_simulation_method is not None:
            start_method = getattr(self, "start_now")

        if conf.config.getboolean("Visualiser",
                                  "have_board") and self.port != None:
            self.visulaiser_listener = VisulaiserListener(
                self.dao.machineTimeStep, self.dao.time_scale_factor)
            self.visulaiser_listener.set_port(self.port)
        else:
            logger.warn("you are running the visualiser without a board."
                        " Aspects of the visualiser may not work")
        self.visulaiser_main = VisualiserMain(self.dao, self, start_method)
        self.visulaiser_listener.set_visualiser(self.visulaiser_main)

        logger.info("[visualiser] Starting")
        if self.visulaiser_listener is not None:
            self.visulaiser_listener.start()

        gtk.threads_enter()
        self.visulaiser_main.main()
        gtk.threads_leave()
        logger.debug("[visualiser] Exiting")
Esempio n. 24
0
 def reg_textbox(self, actor, text):
     gtk.threads_enter()
     entry = gtk.Entry(max=0)
     entry.set_text(text)
     entry.connect("changed", self.ext_changed, actor)
     gtk.threads_leave()
     self.widgets[actor] = entry
Esempio n. 25
0
    def run(self):
        global remaining

        try:
            local = os.path.basename(self.url)
            if not local: local = 'index.html'
            opener.retrieve(self.url, local, reporthook=self.download_status)
        except SystemExit:
            pass
        except:
            traceback.print_exc()

        # if we completed the download, now clean things up.
        gtk.threads_enter()

        self.frame.destroy()
        del self.progress, self.frame

        remaining_lock.acquire()
        remaining -= 1
        value = remaining
        remaining_lock.release()

        if value == 0:
            gtk.main_quit()

        gtk.threads_leave()
Esempio n. 26
0
    def run (self):
        global window
        global image
        #global img_pixmap
        #global img_mask

        self.HOST = 'localhost'
        self.PORT = 50012
        self.s = socket.socket (socket.AF_INET, socket.SOCK_STREAM)
        self.s.bind ((self.HOST, self.PORT))
        self.s.listen (1)

        while not self.stop_socket.isSet ():
            conn, addr = self.s.accept ()
            gtk.threads_enter ()
            data = conn.recv (1024)
            print data

            # Changing the image object to the image needed.
            file_name = os.path.join (imgs_path, data + '.jpg')
            pixbuf = gtk.gdk.pixbuf_new_from_file (file_name)
            pixmap, mask = pixbuf.render_pixmap_and_mask ()
            image.set_from_pixmap (pixmap, mask)
            #image.set_from_pixmap (img_pixmap[int (data) - 1], img_mask[int (data) - 1])

            gtk.threads_leave ()
            conn.close ()

        self.s.close ()
Esempio n. 27
0
        def update():
            gtk.threads_enter()
            try:
                self.updateVoltages()

            finally:
                gtk.threads_leave()
Esempio n. 28
0
 def packend(self, parent, child):
     gtk.threads_enter()
     gtk_parent = self.widgets[parent]
     gtk_child = self.widgets[child]
     gtk_parent.pack_end(gtk_child, expand=False, fill=False, padding=0)
     gtk_child.show()
     gtk.threads_leave()
Esempio n. 29
0
 def set_toupdate(self, num):
     gtk.threads_enter()
     self.set_icon(gtk.STOCK_NO)
     self.w_tooltips.set_tip(self,
                             _("Ilenia-notifier: %i updates available") %
                             num)
     gtk.threads_leave()
Esempio n. 30
0
def testIP(subnet):
    dev = glade.get_widget("interface").get_active_text()
    time = int(glade.get_widget("time").get_active_text())

    for ipEnding in random.sample(range(5, 254), time + 1):
        ip = ".".join((subnet, str(ipEnding)))
        setStatus(info=ip)
        if os.system("ifconfig %s %s up" % (dev, ip)) is not 0:
            gtk.threads_enter()
            errMessage = "You don't have permission to change the IP of device %s.\n" % dev + \
             "Please run this application as super user. I will now exit..."
            msgBox = gtk.MessageDialog(type=gtk.MESSAGE_ERROR,
                                       buttons=gtk.BUTTONS_CLOSE,
                                       message_format=errMessage)
            msgBox.show()
            msgBox.run()
            msgBox.destroy()
            gtk.main_quit()
            gtk.threads_leave()
            return True
        for routerEnding in [1, 2]:
            if "doStopScan" in globals():
                return True
            ip = ".".join((subnet, str(routerEnding)))
            if os.system("arping -qfw %d -I %s %s >/dev/null" %
                         (time, dev, ip)) is 0:
                addLog("\nThe subnet %s seems to have a router at %s" %
                       (subnet, ip))
                return True
    return False
Esempio n. 31
0
	def update_textbuffer_channel(self, channel_name, username, text, tag=None):
	# Updates TextBuffers for chat
		
		for i in range (0,len(self.lobby_channel_names)):
			if self.lobby_channel_names[i] == channel_name:
				gtk.threads_enter()
				iter = self.lobby_channel_buffers[i].get_end_iter()
				self.lobby_channel_buffers[i].insert(iter, '\n')
				iter = self.lobby_channel_buffers[i].get_end_iter()
				if tag == "join":
					self.lobby_channel_buffers[i].insert_with_tags_by_name(iter, text, "join")

				elif tag == "left":
					self.lobby_channel_buffers[i].insert_with_tags_by_name(iter, text, "left")
				elif tag == "topic":
					self.lobby_channel_buffers[i].insert_with_tags_by_name(iter, text, "topic")

				else:
					if username != None:
						self.lobby_channel_buffers[i].insert(iter, '<' + username + '> ')
					self.lobby_channel_buffers[i].insert(iter, text)

				if self.lobby_channel_buffers[i].get_line_count() > 50:
					self.lobby_channel_buffers[i].delete(self.lobby_channel_buffers[i].get_start_iter(), self.lobby_channel_buffers[i].get_iter_at_line(1))
				self.lobby_channel_textview[i].scroll_mark_onscreen(self.lobby_channel_buffers[i].get_insert())
				gtk.threads_leave()
				break
Esempio n. 32
0
	def processSVG_Thread(self, segmentGroups):
		gtk.threads_enter()
		processSVG(segmentGroups)
		
		self.redraw_drawingArea()
		self.indicateLoading(False)
		gtk.threads_leave()
Esempio n. 33
0
 def reg_button(self, actor, text):
     gtk.threads_enter()
     button = gtk.Button(text)
     button.connect("clicked", self.ext_clicked, actor)
     button.show()
     gtk.threads_leave()
     self.widgets[actor] = button
 def setEMStop(self, em):
     if (em):
         #print "Emergency Stop Active"
         gtk.threads_enter()
         self.status_image.set_from_file(
             roslib.packages.get_pkg_dir("cob_command_gui") +
             "/common/files/icons/error.png")
         self.status_label.set_text("EM Stop !")
         gtk.threads_leave()
         if (self.em_stop == False):
             self.em_stop = True
             n = pynotify.Notification("Emergency Stop issued!", "",
                                       "dialog-warning")
             n.set_timeout(1)
             n.show()
     else:
         #print "Status OK"
         self.status_image.set_from_file(
             roslib.packages.get_pkg_dir("cob_command_gui") +
             "/common/files/icons/ok.png")
         gtk.threads_enter()
         self.status_label.set_text("Status OK")
         gtk.threads_leave()
         if (self.em_stop == True):
             self.em_stop = False
             n = pynotify.Notification("Emergency Stop released!", "",
                                       "dialog-ok")
             n.set_timeout(1)
             n.show()
Esempio n. 35
0
    def main(self):
        gtk.threads_enter()

        # Splash
        splash = gtk.Window()
        splash.set_decorated(False)
        splash.set_position(gtk.WIN_POS_CENTER)

        # VBox
        vbox = gtk.VBox(homogeneous=False, spacing=0)
        vbox.show()
        splash.add(vbox)

        # Background
        background = gtk.Image()
        background.set_from_file(self.ini.get(self.profile, "BACKGROUND"))
        background.show()
        vbox.pack_start(background, expand=True, fill=True, padding=0)

        # ProgressBar
        progressbar = gtk.ProgressBar()
        progressbar.show()
        progressbar.set_text("Please Wait")
        vbox.pack_end(progressbar, expand=True, fill=True, padding=0)

        splash.show()
        while gtk.events_pending():
            gtk.main_iteration()
        self.setup(progressbar)
        # 		splash.hide()
        splash.destroy()

        gtk.main()
        gtk.threads_leave()
Esempio n. 36
0
 def packstart(self, parent, child, expand):
     gtk.threads_enter()
     gtk_parent = self.widgets[parent]
     gtk_child = self.widgets[child]
     gtk_parent.pack_start(gtk_child, expand=expand, fill=True, padding=0)
     gtk_child.show()
     gtk.threads_leave()
Esempio n. 37
0
 def __find(self):
     self.status(1, "searching")
     self.__nfound = 0
     for i, filename in enumerate(self.get_files()):
         if i % 16 == 0:
             self.status(self.__nfound)
         try:
             f = open(filename, 'r')
         except IOError:
             continue
         for linenumber, line in enumerate(f):
             if not self.__running:
                 self.__finished()
             if BINARY_RE.match(line):
                 break
             matches = self.__pattern.findall(line)
             if len(matches):
                 self.__nfound = self.__nfound + len(matches)
                 if self.__nfound >= self.__options.maxresults:
                     self.__finished()
                 result = GrepResult(linenumber, filename, line, matches)
                 gtk.threads_enter()
                 self.emit('found', result)
                 gtk.threads_leave()
         f.close()
     self.__finished()
Esempio n. 38
0
    def controlMethod(self):
        while self.mIsRunning:
            gtk.threads_enter()
            try:
                # read motor position 
                rotval = self.read_values_from_canbus() # updates the display too
                
                if self.mMode == RotationApp.MODE_STARTED: # movement going on
                    # stop if target reached 
                    if self.mAxRot.finishedMoving():
                        self.mAxRot.finishMovement()
                        # change the button labels
                        # change button labels
                        self.builder.get_object("startStopButton").set_label("Start")
                        self.builder.get_object("goToZeroButton").set_sensitive(True)
                        self.mMode = RotationApp.MODE_WAITING
                        print "Finished movement in " + str(clock()-self.mStartTime) + " s"

                elif self.mMode == RotationApp.MODE_STARTING:
                    # change button labels
                    self.builder.get_object("startStopButton").set_label("Stop")
                    self.builder.get_object("goToZeroButton").set_sensitive(False)
                    
                    # read the values from controls
                    ctime = self.builder.get_object("counting_time_spin").get_value()
                    cangle = self.builder.get_object("rot_angle_spin").get_value()
                    degpersecond = cangle / ctime
                    print "Going to angle " + str(cangle) + " with speed " + str(degpersecond) + " deg/s"

                    # start the movement
                    self.mAxRot.startMoving(newPos = int(cangle),newSpeed = degpersecond)
                    self.mStartTime = clock()
                    self.mMode = RotationApp.MODE_STARTED
                    
                    
                elif self.mMode == RotationApp.MODE_STOPPING:
                    # stop motor movements
                    self.mAxRot.stopMovement()
                    
                    # change button labels
                    self.builder.get_object("startStopButton").set_label("Start")
                    self.builder.get_object("goToZeroButton").set_sensitive(True)

                    self.mMode = RotationApp.MODE_WAITING
                    
                elif self.mMode == RotationApp.MODE_ZEROING:
                    if self.mAxRot.finishedMoving():
                        print "Zeroing, movement finished"
                        self.mAxRot.finishMovement()
                        self.builder.get_object("startStopButton").set_sensitive(True)
                        self.mMode = RotationApp.MODE_WAITING

                                               
            finally:
                gtk.threads_leave()
                
            sleep(0.1)
                
        print "thread finishing"
Esempio n. 39
0
 def idle_cb(d, thunk):
     gtk.threads_enter()
     d.show()
     d.run()
     d.destroy()
     if thunk:
         thunk()
     gtk.threads_leave()
Esempio n. 40
0
 def put_char(self, c):
     if self.running:
         gtk.threads_enter()
     tb = self.tv_out.get_buffer()
     tb.insert(tb.get_end_iter(), c)
     self.scroll_tv()
     if self.running:
         gtk.threads_leave()
Esempio n. 41
0
 def reg_window(self, actor):
     gtk.threads_enter()
     window = gtk.Window(gtk.WINDOW_TOPLEVEL)
     window.connect("delete_event", self.ext_delete_event, actor)
     window.set_border_width(10)
     window.show()
     gtk.threads_leave()
     self.widgets[actor] = window
Esempio n. 42
0
def addLog(text):
    gtk.threads_enter()
    if text is None:
        glade.get_widget("log").get_buffer().set_text("")
    else:
        glade.get_widget("log").get_buffer().insert(
            glade.get_widget("log").get_buffer().get_end_iter(), "%s\n" % text)
    gtk.threads_leave()
 def do_draw(ini, end, dist_str=None):
     gtk.threads_enter()
     try:
         self.da.window.draw_line(self.gc, ini[0], ini[1], end[0], end[1])
         if dist_str:
             self.da.write_text(self.gc, end[0], end[1], dist_str, 10)
     finally:
         gtk.threads_leave()
def func(label):
    n = 0
    while 1:
        gtk.threads_enter()
        label.set_text(str(n))
        n += 1
        gtk.threads_leave()
        time.sleep(0.1)
Esempio n. 45
0
def func(label):
    n = 0
    while 1:
        gtk.threads_enter()
        label.set_text(str(n))
        n += 1
        gtk.threads_leave()
        time.sleep(0.1)
Esempio n. 46
0
 def put_int(self, i):
     if self.running:
         gtk.threads_enter()
     tb = self.tv_out.get_buffer()
     tb.insert(tb.get_end_iter(), str(i))
     self.scroll_tv()
     if self.running:
         gtk.threads_leave()
Esempio n. 47
0
 def do_pulse(self):
     while self.pulse:
         gtk.threads_enter()
         self.gld.get_widget("prog_bar").pulse()
         gtk.threads_leave()
         time.sleep(0.5)
     self.gld.get_widget("prog_bar").set_fraction(1.0)
     return
Esempio n. 48
0
 def idle_cb(d, thunk):
     gtk.threads_enter()
     d.show()
     d.run()
     d.destroy()
     if thunk:
         thunk()
     gtk.threads_leave()
Esempio n. 49
0
def setStatus(percent=None, info=None):
    gtk.threads_enter()
    if percent is not None:
        glade.get_widget("progress").set_fraction(percent)
        glade.get_widget("progress").set_text("%.2f%%" % (percent * 100))
    if info is not None:
        glade.get_widget("information").set_text(info)
    gtk.threads_leave()
Esempio n. 50
0
 def main(self):
     self.connect_with_server()
     self.update_liststore()
     self.listWindow.show()
     gtk.threads_init()
     gtk.threads_enter()
     gtk.main()
     gtk.threads_leave()
Esempio n. 51
0
def ProgressUpdate(progress_id, fraction):
    # print >>raw_stderr, "Updating progress bar", progress_id,"to fraction",fraction
    raw_stderr.flush()
    if progress_id >= 0:
        gtk.threads_enter()
        pb = plide_main_window.get_progress_from_id(progress_id)
        pb.set_fraction(fraction)
        gtk.threads_leave()
Esempio n. 52
0
 def do_draw(ini, end, dist_str=None):
     gtk.threads_enter()
     try:
         self.da.window.draw_line(self.gc, ini[0], ini[1], end[0], end[1])
         if dist_str:
             self.da.write_text(self.gc, end[0], end[1], dist_str, 10)
     finally:
         gtk.threads_leave()
Esempio n. 53
0
 def updateProgressDialog(self, count, totalLen, progress, layerName):
     if self.threadNotifyType == 1:
         gtk.threads_enter()
         self.progressDialog.updateProgess(count, totalLen, progress,
                                           layerName)
         gtk.threads_leave()
     else:
         glib.idle_add(self.progressDialog.updateProgess, count, totalLen,
                       progress, layerName)
Esempio n. 54
0
def ReleaseProgressBar(progress_id):
    # print >>raw_stderr, "Releasing progress bar", progress_id
    raw_stderr.flush()
    if progress_id >= 0:
        gtk.threads_enter()
        pb = plide_main_window.get_progress_from_id(progress_id)
        pb.set_fraction(1.0)  # Make it complete on screen
        gtk.threads_leave()
        plide_main_window.release_progress(progress_id)
Esempio n. 55
0
 def scroll_and_wait(self, amount, lock_held):
     if not lock_held:
         gtk.threads_enter()
     self.scroll_by(0, amount)
     if not lock_held:
         gtk.threads_leave()
     if self.vscrolltimeout is not None:
         gobject.source_remove(self.vscrolltimeout)
     self.vscrolltimeout = gobject.timeout_add(100, self.scroll_and_wait, amount, False)
Esempio n. 56
0
 def received(self, url, page, text):
     '''Sets the members when getting paste url'''
     url = self.parse(url, page)
     self.set_text(text)
     self.set_url(url)
     gtk.threads_enter()
     self.__pastes.push(self)
     self.__close_editor()
     gtk.threads_leave()
Esempio n. 57
0
 def on_menuitem_clicked(item):
     gtk.threads_leave()
     label = item.get_label()
     if label == 'Quit':
         gtk_main_quit()
     elif label in streams.keys():
         player.play_stream(None, label, streams[label])
         player.start()
     print "CLICKED:%s " % (item.get_label())
Esempio n. 58
0
 def write(self, level, msg):
     # insert message
     message = self.formatter(level, msg)
     self.buffer.insert_with_tags_by_name(self.buffer.get_end_iter(),
                                          message, level)
     # scroll
     mark = self.buffer.get_mark("insert")
     self.statView.scroll_mark_onscreen(mark)
     gtk.threads_leave()
Esempio n. 59
0
File: test_gtk.py Progetto: ur2/temp
 def progress(self, download_t, download_d, upload_t, upload_d):
     if download_t == 0:
         self.round = self.round + 0.1
         if self.round >= 1.0:  self.round = 0.0
     else:
         self.round = float(download_d) / float(download_t)
     gtk.threads_enter()
     self.pbar.set_fraction(self.round)
     gtk.threads_leave()