Welcome Guest ( Log In | Register )

Outline · [ Standard ] · Linear+

 Read .txt file in Glade GUI, python + glade

views
     
oshiri
post Apr 10 2009, 03:08 PM

Enthusiast
*****
Senior Member
751 posts

Joined: Nov 2004
That error from dpkg --build?
It was my mistake...sorry. I have it repaired.
It should be:
dpkg --build tepache_1.1-5_all

Kefir came from the same author of tepache.
Probably new name for tepache.
I tried it..but it always give me syntax error.

Autconnect function and most of the function is called from SimpleGladeApp.py.
No need to touch this file.
You only need to modified py file with the same name of your glade file... see my example on radio button.


Added on April 10, 2009, 3:52 pmIf you want to compile tepache from source, get the source from debian (I can't find the original source from their site):
wget http://ftp.de.debian.org/debian/pool/main/...1.1.orig.tar.gz
wget http://ftp.de.debian.org/debian/pool/main/...e_1.1-5.diff.gz

Extract both file. I use unp ( get it using apt-get install unp):
unp tepache_1.1.orig.tar.gz
unp tepache_1.1-5.diff.gz

cd to tepache folder:
cd tepache-1.1

patch file:
patch -p1 < ../tepache_1.1-5.diff

Change permission:
chmod -R 777 debian

Build package:
dpkg-buildpackage -rfakeroot

Install:
cd ..
dpkg -i tepache_1.1-5_all.deb




This post has been edited by oshiri: Apr 10 2009, 03:52 PM
TSLaw
post Apr 10 2009, 04:55 PM

Getting Started
**
Junior Member
134 posts

Joined: Apr 2005
I think i have success installed tepache, nothing was appeared.
How am i going to start the tepache?

I also modified the name in glade with the same as your code, but it show me error:

ImportError: No module named SimpleGladeApp

Attached you a printscreen photo of installation result:




Attached thumbnail(s)
Attached Image
oshiri
post Apr 10 2009, 06:59 PM

Enthusiast
*****
Senior Member
751 posts

Joined: Nov 2004
Don't simply use my code. Use it as example only.
That code are based on my glade file.

To use tepache, enter the folder where your glade file resides.
Then run : tepache yourgladefile.glade
It wiil create SimpleGladeApp.py and yourgladefile.py yourgladefile.py.ori

example:
CODE
$ ls
tutorial.glade

$ tepache tutorial.glade
written file tutorial.py

$ ls
SimpleGladeApp.py  tutorial.glade  tutorial.py  tutorial.py.orig


Then test your py file (created by tepache).
Your gui will popup but nothing will works. Try clicking on button you created, you will see output on terminal.
That output will give you some clue.

For example:
When you click close button it will show:
on_button1_clicked called with self.button1

That will give you a clue which line you should edit.

Close your gui using ctrl + c.

Edit your py file, find def on_button1_clicked(self, widget, *args):
Then add:
gtk.main_quit()

Now the close button will work and really close your window.

p/s
I am in the process of creating tutorial on how to use pygtk, glade and tepache.
When it is done, it will be on my website.

This post has been edited by oshiri: Apr 10 2009, 07:01 PM
TSLaw
post Apr 10 2009, 07:12 PM

Getting Started
**
Junior Member
134 posts

Joined: Apr 2005
okok...terima kasih you...

looking forward your tutorial, once completed remember drop me a msg...

i will try it later...
oshiri
post Apr 11 2009, 05:44 PM

Enthusiast
*****
Senior Member
751 posts

Joined: Nov 2004
I just release glade2 with simplegladepython patched for debian.
This will integrate glade2 and tepache.
No need to run tepache manually from command line, just hit Build button on glade (after you set option and save your file).

user posted image

Get it from my site:
http://mambang.org.my/modules/news/
TSLaw
post Apr 11 2009, 11:09 PM

Getting Started
**
Junior Member
134 posts

Joined: Apr 2005
I have tried to build the radiobutton tutorial by tepache, but all the windows is pop up when i run the file.

Can i hide the other windows initially, window will pop up only when particular radiobutton is selected.?


Added on April 11, 2009, 11:18 pmIt seems like quite complicated to construct huh...?

So all i need now is download the file:

1. glade_2.12.1-7_i386.deb
2. glade-common_2.12.1-7_i386.deb
3. tepache_1.1-5_all.deb

For 1 and 3, i think i got in my linux, but i have no idea about 2...

How to start with this 3 files..?

This post has been edited by Law: Apr 11 2009, 11:20 PM
TSLaw
post Apr 12 2009, 12:27 AM

Getting Started
**
Junior Member
134 posts

Joined: Apr 2005
Am i correct if i want to run a command when a button is clicked, in the mean time save the output to txt file.

CODE
def show_searching(self, obj):
 os.system('dmesg > output.txt')
 self.searching.show()
 return True

(example for command dmesg )

Additional problem
I have a doubt, whether possible to run 2 or 3 command with ONLY ONE button is clicked???

Thanks for advise!!!

This post has been edited by Law: Apr 12 2009, 12:32 AM
oshiri
post Apr 12 2009, 07:59 AM

Enthusiast
*****
Senior Member
751 posts

Joined: Nov 2004
The package is in gzip. Extract it and you'll get all 3 files.
Since you already got tepache installed, you only need to install 2 first, then followed by 1.

QUOTE
Can i hide the other windows initially, window will pop up only when particular radiobutton is selected.?

See at the bottom of your python code, you'll find:
def main():

Comment (#) other windows you don't want to popup except the first window.
Look at my example, only window1 is shown.

CODE
def main():
  window1 = Window1()
  #window2 = Window2()
  #window3 = Window3()
  #window4 = Window4()


QUOTE
Am i correct if i want to run a command when a button is clicked, in the mean time save the output to txt file.

See at my previous example on using temporary file and read it latter and send it to textview.

QUOTE
I have a doubt, whether possible to run 2 or 3 command with ONLY ONE button is clicked???

Yes you can. Add your command to the same signal. You can use sleep in between command to wait for one command to finish then run another command.



This post has been edited by oshiri: Apr 12 2009, 08:02 AM
TSLaw
post Apr 13 2009, 10:14 AM

Getting Started
**
Junior Member
134 posts

Joined: Apr 2005
On my second window, there is also a radiobutton (eg: radiobutton5)...but tepache only show the radiobutton signal until radiobutton4 (which is on first window)...

It seems like it doesn't link up all the signal button?
Or i did any mistakes?
oshiri
post Apr 13 2009, 10:59 AM

Enthusiast
*****
Senior Member
751 posts

Joined: Nov 2004
Do you mind pasting your glade file or python file or both?
TSLaw
post Apr 13 2009, 11:21 AM

Getting Started
**
Junior Member
134 posts

Joined: Apr 2005
ok...sure...but i need to go out now...
i will paste on here by tonight, you can take your time to see...

thanks...
TSLaw
post Apr 13 2009, 05:38 PM

Getting Started
**
Junior Member
134 posts

Joined: Apr 2005
Hi Oshiri,

This is my glade file together with python file.

Hope you can take a look on it...

Thanks...



This post has been edited by Law: Apr 13 2009, 06:23 PM


Attached File(s)
Attached File  radiobutton.tar.gz ( 8.67k ) Number of downloads: 6
TSLaw
post Apr 13 2009, 06:25 PM

Getting Started
**
Junior Member
134 posts

Joined: Apr 2005
Btw, i try to write the code by myself with python...

In the glade file, i connect radiobutton signal as below

CODE

"on_radiobutton1_toggled" : self.on_radiobutton1,
"on_radiobutton2_toggled" : self.on_radiobutton2,
"on_button1_clicked" : self.window_show


how should i define "self.window_show" in order to let the window2 and window3 show up when button is clicked?

I do it as this way...


CODE


def window_show(self, widget, *args):
 if self.on_radiobutton1.get_active():
  self.window2.show()
 
 if self.on_radiobutton2.get_active():
  self.window3.show()


It show me error that couldn't create the XML file, so i think i need to define the "on_radiobutton1" & on_radiobutton2"

What should i put for this?

This is my first try, i will continue trying...
oshiri
post Apr 13 2009, 09:20 PM

Enthusiast
*****
Senior Member
751 posts

Joined: Nov 2004
QUOTE
On my second window, there is also a radiobutton (eg: radiobutton5)...but tepache only show the radiobutton signal until radiobutton4 (which is on first window)...

It seems like it doesn't link up all the signal button?
Or i did any mistakes?


Check again your glade file.
Start from radiobutton4 and above you did not define signal.
That is why tepache does not produce code for those buttons.


QUOTE
how should i define "self.window_show" in order to let the window2 and window3 show up when button is clicked?

Not sure what you want to do. Poping both wiindows at the same time?
If that the case, I don't thing it possible with radio button. Probably you need to use toggle button.

QUOTE
def window_show(self, widget, *args):
if self.on_radiobutton1.get_active():
  self.window2.show()
 
if self.on_radiobutton2.get_active():
  self.window3.show()

Try use widget name rather then signal handler.
ex: if self.radiobutton1.get_active()
TSLaw
post Apr 13 2009, 11:11 PM

Getting Started
**
Junior Member
134 posts

Joined: Apr 2005
QUOTE(oshiri @ Apr 13 2009, 09:20 PM)
Not sure what you want to do. Poping both wiindows at the same time?
If that the case, I don't thing it possible with radio button. Probably you need to use toggle button.
Nope, i want only a window is pop up each time when button is clicked...just like the glade+python file i attached...but write the code manually...
Can you do me a favor, show me how to do this?
The same thing of radiobutton example, but can show how to construct the code manually??

QUOTE
Check again your glade file.
Start from radiobutton4 and above you did not define signal.
That is why tepache does not produce code for those buttons.
I keep checking on first window, but never notice the mistake here...
Thanks...

This post has been edited by Law: Apr 14 2009, 02:23 AM
TSLaw
post Apr 14 2009, 01:07 AM

Getting Started
**
Junior Member
134 posts

Joined: Apr 2005
Hi oshiri,

I tried to use tepache to compile, i cant fetch the txt file to my textview...

I saw there is a place for us to write in our own code...

oshiri
post Apr 15 2009, 12:43 AM

Enthusiast
*****
Senior Member
751 posts

Joined: Nov 2004
Manual code:

CODE
#!/usr/bin/env python

import sys

try:
       import pygtk
       pygtk.require("2.0")
except:
       pass
try:
       import gtk
       import gtk.glade
except:
       sys.exit(1)

class Window1:

       def __init__(self):

               self.gladefile = "project8.glade"
               self.root = "window1"
               self.wTree = gtk.glade.XML(self.gladefile, self.root)

               dic = { "on_window1_destroy" : gtk.main_quit,
                       "on_button1_clicked": self.on_button1_clicked,
                       "on_button2_clicked": gtk.main_quit
                       }

               self.wTree.signal_autoconnect(dic)

       def on_button1_clicked(self, widget, *args):
               if self.wTree.get_widget("radiobutton1").get_active():
                       Window2()

               if self.wTree.get_widget("radiobutton2").get_active():
                       Window3()

               if self.wTree.get_widget("radiobutton3").get_active():
                       Window4()
class Window2:

       def __init__(self):

               self.gladefile = "project8.glade"
               self.root = "window2"
               self.wTree = gtk.glade.XML(self.gladefile, self.root)

               dic = { "on_window1_destroy" : gtk.main_quit
                       }

               self.wTree.signal_autoconnect(dic)


class Window3:

       def __init__(self):

               self.gladefile = "project8.glade"
               self.root = "window3"
               self.wTree = gtk.glade.XML(self.gladefile, self.root)

               dic = { "on_window1_destroy" : gtk.main_quit
                       }

               self.wTree.signal_autoconnect(dic)

class Window4:

       def __init__(self):

               self.gladefile = "project8.glade"
               self.root = "window4"
               self.wTree = gtk.glade.XML(self.gladefile, self.root)

               dic = { "on_window1_destroy" : gtk.main_quit
                       }

               self.wTree.signal_autoconnect(dic)


if __name__ == "__main__":
       Window1()
       gtk.main()


No need to define all radiobuttons signal as I call widget directly.


CODE
I tried to use tepache to compile, i cant fetch the txt file to my textview...

Cannot help without looking at your code.


TSLaw
post Apr 15 2009, 01:07 AM

Getting Started
**
Junior Member
134 posts

Joined: Apr 2005
Oh man...
I tried the radiobutton for almost one week...but got nothing...

You are my god man...

I really really wish to see your glade + python + tepache tutorial soon...

Hope to hear you soon....


Added on April 15, 2009, 1:17 amA question to ask you here, if i just want the particular window show, i can ignore the class window 2 - 4 ??

By the way, the way you did is more tidy and easy to let others understand...

And i curious that, there are a lot of ways writing the code with python, sometimes really make me pening....

I will keep learning...




This post has been edited by Law: Apr 15 2009, 01:17 AM
oshiri
post Apr 15 2009, 11:19 AM

Enthusiast
*****
Senior Member
751 posts

Joined: Nov 2004
QUOTE
A question to ask you here, if i just want the particular window show, i can ignore the class window 2 - 4 ??

Yes. Just create class you want to use.

QUOTE
And i curious that, there are a lot of ways writing the code with python, sometimes really make me pening....

Hehe... name of the language = python (ular sawa) ..always belit belit la.
If you are familiar with bash scripting concept, you'll find any scripting language not that hard.
TSLaw
post Apr 15 2009, 02:07 PM

Getting Started
**
Junior Member
134 posts

Joined: Apr 2005
QUOTE(oshiri @ Apr 15 2009, 11:19 AM)
Hehe... name of the language = python (ular sawa) ..always belit belit la.
If you are familiar with bash scripting concept, you'll find any scripting language not that hard.
*
HAHA...funny and good answer...

I want stick one way in writing python first...after i getting familiar with this, i will learn other...

Bash script is something like C programming ??

3 Pages < 1 2 3 >Top
 

Change to:
| Lo-Fi Version
0.1077sec    0.50    6 queries    GZIP Disabled
Time is now: 19th December 2025 - 01:22 AM