PHP-GTK2 Cookbook Forum
Welcome, Guest
Please Login or Register.    Lost Password?
A button with an image in it in a Treeview (1 viewing) (1) Guest
Go to bottom Post Reply Favoured: 0
TOPIC: A button with an image in it in a Treeview
#190
gianiaz (User)
Fresh Boarder
Posts: 4
graphgraph
User Offline Click here to see the profile of this user
A button with an image in it in a Treeview 2 Months, 2 Weeks ago Karma: 0  
Hi, I'm very new to php-gtk, then apoligize if a ask for stupid questions...

Starting from this code:
http://www.kksou.com/php-gtk2/articles/display-a-2D-array-in-GtkTreeView---Part-1.php

I Wrote a little peace of code that display data from a database.

The listed data is part of a little program to manage my activities.

A sample table could be:

Code:
| / | Project/Activity | Time   |
| + | Project 1        | 0:00:00|
| - | Activity 1       | 0:00:00|
| - | Activity 2       | 0:00:00|
Now what I want to do is to substitute the "minus" sign with a gtkbutton that makes start the timer on the right, but don't know how to do it. I saw that it is possible to put a GtkCellRendererCombo in a tree view, but I didn't found something similar for buttons. Can you help me? thank you
 
  The administrator has disabled public write access.
#191
kksou (Admin)
Admin
Posts: 149
graph
User Online Now Click here to see the profile of this user
Re:A button with an image in it in a Treeview 2 Months, 2 Weeks ago Karma: 6  
Hi Giovanni,

Here's a sample code:

Sample Code 490: How to have a start stop button in GtkTreeView - Part 1 - using liststore



Is this what you have in mind?

Regards,
/kksou
 
 
Last Edit: 2008/05/07 03:59 By kksou.
  The administrator has disabled public write access.
#192
gianiaz (User)
Fresh Boarder
Posts: 4
graphgraph
User Offline Click here to see the profile of this user
Re:A button with an image in it in a Treeview 2 Months, 2 Weeks ago Karma: 0  
Uhaaa... Are you a sort of superhero? :D

Thank you very much, it's what I was looking for.

Bye :)
 
  The administrator has disabled public write access.
#193
kksou (Admin)
Admin
Posts: 149
graph
User Online Now Click here to see the profile of this user
Re:A button with an image in it in a Treeview 2 Months, 2 Weeks ago Karma: 6  
Hi Giovanni,

I believe your project-activity should be in a treestore instead of a liststore.

But I decide to write Part 1 using liststore first as it is more straightforward.

I will write another sample code (Part 2) tomorrow using treestore...

Regards,
/kksou
 
 
Last Edit: 2008/05/06 17:15 By kksou.
  The administrator has disabled public write access.
#194
kksou (Admin)
Admin
Posts: 149
graph
User Online Now Click here to see the profile of this user
Re:A button with an image in it in a Treeview 2 Months, 2 Weeks ago Karma: 6  
Hi Giovanni,

Here's a sample code using Tree Store instead of List Store. I think this should be closer to what you have in mind.

Sample Code 491: How to have a start stop button in GtkTreeView - Part 2 - using treestore



Regards,
/kksou
 
 
Last Edit: 2008/05/07 04:09 By kksou.
  The administrator has disabled public write access.
#195
gianiaz (User)
Fresh Boarder
Posts: 4
graphgraph
User Offline Click here to see the profile of this user
Re:A button with an image in it in a Treeview 2 Months, 2 Weeks ago Karma: 0  
Yes, this way is better.

I began looking at your code, 3 little notes:

1. Didn't understand, but on my pc your code make timer start from 1 hour.
2. For the example purpose the use of date function is ok, but if your attivity takes more than 24 hours you'll have a problem (form my purpose I will write a function that formats the timestamp in $alot_of_hours:minutes:seconds, where $alot_of_hours could be greater than 24).
3. The timer start also if you click on the blank image, I've introduced in your code (line 148)
// (It's the only way I see to know if the clicked image is a project and not an activity, please tell me if exists a better way :-)
if(count($path) > 1) {

}

Thank you again for your exaustive and clean answers, never found a site like this one, It should exist a site like this one for every language :-)
 
  The administrator has disabled public write access.
#196
gianiaz (User)
Fresh Boarder
Posts: 4
graphgraph
User Offline Click here to see the profile of this user
Re:A button with an image in it in a Treeview 2 Months, 2 Weeks ago Karma: 0  
For note 1, I think is a Timezone related problem.

I've another question, there's a way to retrieve the model of the parent row starting from the clicked element?

My purpose is to update the grandtotal timer for the project in real time or when the stop button is clicked.

Bye
 
  The administrator has disabled public write access.
#197
kksou (Admin)
Admin
Posts: 149
graph
User Online Now Click here to see the profile of this user
Re:A button with an image in it in a Treeview 2 Months, 2 Weeks ago Karma: 6  
gianiaz wrote:
For note 1, I think is a Timezone related problem.

I've another question, there's a way to retrieve the model of the parent row starting from the clicked element?

My purpose is to update the grandtotal timer for the project in real time or when the stop button is clicked.


Hi Giovanni,

Here's Part 3 that shows the realtime update of total time elpased for the project:

Sample Code 492: How to have a start stop button in GtkTreeView - Part 3 - update parent



Note:
1. Have also added a new format_time() function that doesn't use the date() function. It also works with time greater than 24 hours. Please see if this one works on your machine.

2. To prevent user from clicking the button_blank32.gif, you method works fine. Alternatively, you can check for
Code:
if ($model[$path][8]==0)
. For projects, parent=0, so column 8 will be 0. Regards, /kksou
 
  The administrator has disabled public write access.
Go to top Post Reply
Powered by FireBoardget the latest posts directly to your desktop

Copyright © 2006-2008. kksou.com. All Rights Reserved