python pygtk deiconify and show not working with threading

Post here if you need help with creating a Graphical User Interface in Python.

python pygtk deiconify and show not working with threading

Postby miamia » Thu Oct 17, 2013 6:25 pm

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: Select all
# -*- 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()
Last edited by micseydel on Thu Oct 17, 2013 6:40 pm, edited 1 time in total.
Reason: First post lock.
miamia
 
Posts: 1
Joined: Thu Oct 17, 2013 6:23 pm

Re: python pygtk deiconify and show not working with threadi

Postby micseydel » Thu Oct 17, 2013 6:43 pm

Moved to GUI section.

I tend not to read GUI-related posts, but I will say, that code is considered messy. Imports should come before function definitions, and names like "jj, "xx", "hooo" and "okno" are very unhelpful for a reader of the code.
Join the #python-forum IRC channel on irc.freenode.net!
User avatar
micseydel
 
Posts: 929
Joined: Tue Feb 12, 2013 2:18 am
Location: Mountain View, CA


Return to GUI

Who is online

Users browsing this forum: No registered users and 2 guests