GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Tue Oct 21, 2014 6:25 pm

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: python deiconify and show is not working with threading
PostPosted: Thu Oct 17, 2013 6:21 pm 
Offline

Joined: Thu Oct 17, 2013 6:02 pm
Posts: 1
Hello,
please in function topko there are deiconify() and show() in my code but it will not show my window. Please how can should I change it?

my code:
Code:
# -*- coding: utf-8 -*-
import sys       
import traceback 
import os
import threading
import psutil

def we_are_frozen():
  return hasattr(sys, "frozen")

def module_path():
  encoding = sys.getfilesystemencoding()
  if we_are_frozen():
    return os.path.dirname(unicode(sys.executable, encoding))
  return os.path.dirname(unicode(__file__, encoding))
 
os.environ['LANGUAGE'] = "en"
import elib.intl                 
import pygtk
pygtk.require("2.0")
import gtk
import gobject
import urllib2
import datetime
import time, platform
from _winreg import *
import warnings
warnings.simplefilter('ignore', Warning)


def hooo(err, ret=None, error=''):
  print traceback.format_exc()
  print err
  while gtk.events_pending():
    gtk.main_iteration()
  gtk.gdk.flush()
  gtk.threads_leave()
  topko()
  topko()

def topko():
  app.okno.deiconify()
  gdkwin = app.okno.window
  gdkwin.set_keep_above(True)
  gdkwin.set_keep_above(False)
  gdkwin.show() 

class jj:
    def __init__(self):

        local_path=os.path.join(module_path(), "lg")   
        elib.intl.install('translation', local_path)     
        self.okno = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.okno.iconify()
        self.okno.resize(400,50)
        self.okno.show_all()
                                   
        #self.xx()

    def play(self):
        threading.Thread(target=self.xx).start()
   
    def xx(self):
      db="a.s"
      if os.path.isfile(db.decode('utf8').replace('\\','/')) == False:
        hooo('5','') 
        return False 

if __name__ == "__main__":
    gtk.threads_init()
    app = jj()
    app.play()
   
    gtk.threads_enter()
    gtk.main()
    gtk.threads_leave()


Top
 Profile  
 
 Post subject: Re: python deiconify and show is not working with threading
PostPosted: Wed Oct 23, 2013 2:24 pm 
Offline
Never Seen the Sunlight

Joined: Mon Apr 28, 2008 5:52 am
Posts: 764
Location: UK
Hi,

You have a number of problems with your code. Your main problem is that you have not used the GDK thread lock correctly and that they are unbalanced. Also note that this code even with corrections would not work under any version of Microsoft Windows.

The best way would be to not use threads in this case.

_________________
E.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group