It seems that I did not understand.
#check_thread
#update_gui
I thought that when thread.start() is called then it is called on the
"background"
Could it be the problem related with visibility_event of TextView?
best regards
On 05/22/2013 05:31 PM, Marco Antonio Islas Cruz wrote:
Looks like you are updating the TextView buffer from other place different than the main
thread, Gtk is thread aware but not thread safe, it can't handle GUI updates outside the
main thread. What I've done is "watch" a variable in the child thread and
update (in the main thread) the GUI if required.
you can use gtk.events_pending() in a loop to make sure the gui is not frozen
when checking the child thread.
while True:
# check_thread
# update_gui
while gtk.events_pending():
gtk.main_iteration_do(False)
On May 22, 2013, at 6:50 AM, Petr Hracek <phra...@redhat.com> wrote:
Hi,
I have following class and problem is that Thread is started but after a short
time it is something like paused.
I could not find any reason why.
GUI looks like Window -> Box -> Textview and Cancel Button in VBox widget.
The aim is to open this window and run in thread some application and output of
that application will be logged in TextView widget
Do you have any idea?
# -*- coding: utf-8 -*-
"""
Created on Wed Apr 3 13:16:47 2013
@author: Petr Hracek
"""
import sys
import logging
import mainWindow
import pathWindow
import argparse
import threading
from devassistant.logger import logger
from gi.repository import Gtk
from devassistant import path_runner
from devassistant import exceptions
class RunLoggingHandler(logging.Handler):
def __init__(self, textbuffer):
logging.Handler.__init__(self)
self.textbuffer = textbuffer
def emit(self, record):
text_iter = self.textbuffer.get_end_iter()
self.textbuffer.insert(text_iter,"{0}\n".format(record.getMessage()))
class ThreadDevAssistantClass(threading.Thread):
def __init__(self, runWin):
threading.Thread.__init__(self)
self.runWin = runWin
def run(self):
self.tlh = RunLoggingHandler(self.runWin.textbuffer)
logger.addHandler(self.tlh)
path =
self.runWin.assistant.get_selected_subassistant_path(**self.runWin.parent.kwargs)
pr = path_runner.PathRunner(path, self.runWin.parent.kwargs)
try:
# This is not thread
pr.run()
except exceptions.ExecutionException as ex:
pass
class runWindow(object):
def __init__(self, parent, finalWindow, builder, assistant):
self.parent = parent
self.finalWindow = finalWindow
self.runWindow = builder.get_object("runWindow")
self.textViewLog = builder.get_object("textViewLog")
self.textbuffer = self.textViewLog.get_buffer()
self.textViewLog.set_wrap_mode(Gtk.WrapMode.WORD_CHAR)
self.assistant = assistant
def open_window(self, widget, data=None):
dirname, projectname = self.parent.pathWindow.get_data()
self.runWindow.show_all()
def visibility_event(self, widget, data=None):
logger.info("Visibility event")
thread = ThreadDevAssistantClass(self)
thread.start()
On 05/16/2013 11:00 AM, Petr Hracek wrote:
Hi Timo,
thank it helps during the showing.
But I think that my way was wrong.
Let's say that I would like to run some command which takes 10minutes (like yum
installation under Linux)
and I would like to track in TextView all actions.
I think that python thread would be needed, right?
How to solve that issues?
Or are there any other possibilities?
Best regards / S pozdravem
Petr Hracek
On 05/14/2013 10:22 AM, Timo wrote:
Op 14-05-13 09:34, Petr Hracek schreef:
Hi folks,
I have a little bit simple question
In Glade3 I have GtkWindow object
with GtkButton and TextView widget.
What is my goal.
I would like to run some actions when all widgets (like TextView, GtkButton)
are really visible.
It means when this condition is satisfied then some actions are run and output
of that actions
are logged into TextView widget.
Actually now I could not find what event should be used for.
It should be some event of GtkWindow, right?
There are some events like visibility_event or show_event, ...
Any advises?
You probable want the realize signal.
window.connect("realize", on_realize)
This will be called when the window is fully shown. This can also be used for
seperate widgets as it's a GtkWidget signal.
Timo
_______________________________________________
pygtk mailing list pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/
_______________________________________________
pygtk mailing list pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/
--
Best regards / S pozdravem
Petr Hracek
_______________________________________________
pygtk mailing list pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/
Marco Antonio Islas Cruz
mar...@islascruz.org
--
Best regards / S pozdravem
Petr Hracek
_______________________________________________
pygtk mailing list pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/