Re: [PD-dev] pd.tk question

2009-10-31 Thread Hans-Christoph Steiner


On Oct 30, 2009, at 10:24 PM, Ivica Ico Bukvic wrote:


Hey Ivica,

Just make it a global, that's the easiest.  Or use namespaces and
namespace variables.

.hc


I am not all that good with tk. Only learned what I had to to hack
together better version of pd.tk. Any examples would be most
appreciated. How do namespaces work?

Also, after opening tons of windows that generate global variables,
doesn't this effectively produce a minor but nonetheless present  
memory

leak as the global variables will be hard to trace when deallocating
those windows (see my other email re: improvements)?

Ico


Look at the new pd-gui-rewrite branch, it uses namespaces a fair  
amount.  They are a bit overcomplicated in Tcl, but you don't have to  
use the complicated parts.


.hc






kill your television



___
Pd-dev mailing list
Pd-dev@iem.at
http://lists.puredata.info/listinfo/pd-dev


Re: [PD-dev] pd.tk question

2009-10-31 Thread András Murányi
On Sat, Oct 31, 2009 at 7:00 PM, Hans-Christoph Steiner h...@at.or.atwrote:


 On Oct 30, 2009, at 10:24 PM, Ivica Ico Bukvic wrote:

  Hey Ivica,

 Just make it a global, that's the easiest.  Or use namespaces and
 namespace variables.

 .hc


 I am not all that good with tk. Only learned what I had to to hack
 together better version of pd.tk. Any examples would be most
 appreciated. How do namespaces work?

 Also, after opening tons of windows that generate global variables,
 doesn't this effectively produce a minor but nonetheless present memory
 leak as the global variables will be hard to trace when deallocating
 those windows (see my other email re: improvements)?

 Ico


 Look at the new pd-gui-rewrite branch, it uses namespaces a fair amount.
  They are a bit overcomplicated in Tcl, but you don't have to use the
 complicated parts.

 .hc


Hans, when you have a few minutes can you just sum up quickly how does it go
with namespaces? I've familiarized easy with everything else in the sources,
but i couldn't get namespaces do anything (thus my tabbed-console plugin
doesn't see the popupmode setting).

Btw, i would be happy to clean up pdtk_post as suggested by the comments,
but i have questions:
- this should be switchable between Pd window and stderr: how do you
imagine this; a command line switch or from preferences...?
- you mentioned you would shift popupmode to a plugin, is it ok if i give it
a shot?

Andras
___
Pd-dev mailing list
Pd-dev@iem.at
http://lists.puredata.info/listinfo/pd-dev


Re: [PD-dev] pd.tk question

2009-10-31 Thread Hans-Christoph Steiner


On Oct 31, 2009, at 3:12 PM, András Murányi wrote:




On Sat, Oct 31, 2009 at 7:00 PM, Hans-Christoph Steiner  
h...@at.or.at wrote:


On Oct 30, 2009, at 10:24 PM, Ivica Ico Bukvic wrote:

Hey Ivica,

Just make it a global, that's the easiest.  Or use namespaces and
namespace variables.

.hc

I am not all that good with tk. Only learned what I had to to hack
together better version of pd.tk. Any examples would be most
appreciated. How do namespaces work?

Also, after opening tons of windows that generate global variables,
doesn't this effectively produce a minor but nonetheless present  
memory

leak as the global variables will be hard to trace when deallocating
those windows (see my other email re: improvements)?

Ico

Look at the new pd-gui-rewrite branch, it uses namespaces a fair  
amount.  They are a bit overcomplicated in Tcl, but you don't have  
to use the complicated parts.


.hc


Hans, when you have a few minutes can you just sum up quickly how  
does it go with namespaces? I've familiarized easy with everything  
else in the sources, but i couldn't get namespaces do anything (thus  
my tabbed-console plugin doesn't see the popupmode setting).


Here are the basics:

Create a namespace 'pdwindow' with the variable 'printout_buffer' in it:
namespace eval pdwindow {
variable printout_buffer
...
}

use the 'printout_buffer' variable anywhere with the namespace prefix:
puts $::pdwindow::printout_buffer


Create a proc in the 'pdwindow' namespace and use 'printout_buffer'  
without the prefix:

proc ::pdwindow::pdtk_post {message} {
variable printout_buffer
puts $printout_buffer
...
}

Call the pdtk_post proc from anywhere:

::pdwindow::pdtk_post blah blah

All the pdtk_post proc to be used outside of the 'pdwindow' namespace:
namespace eval pdwindow {
...
namespace export pdtk_post
...
}

Use the 'pdtk_post' proc from the pdwindow namespace globally without  
the prefix

namespace import ::pdwindow::pdtk_post
pdtk_post blah blah


Btw, i would be happy to clean up pdtk_post as suggested by the  
comments, but i have questions:
- this should be switchable between Pd window and stderr: how do  
you imagine this; a command line switch or from preferences...?
- you mentioned you would shift popupmode to a plugin, is it ok if i  
give it a shot?


Sure, but I recently fixed those two, thanks to mescalinum's  
opt_parser code. :)  I suppose I should remove the TODO...


.hc





kill your television


___
Pd-dev mailing list
Pd-dev@iem.at
http://lists.puredata.info/listinfo/pd-dev


Re: [PD-dev] pd.tk question

2009-10-30 Thread Hans-Christoph Steiner


Hey Ivica,

Just make it a global, that's the easiest.  Or use namespaces and  
namespace variables.


.hc

On Oct 29, 2009, at 12:08 PM, Ivica Ico Bukvic wrote:


Hi all,

Is there a way to declare a variable within a proc scope so that it  
can

be referenced later externally? e.g. having $name.something in
pdtk_canvas_new linked to a widget can be easily referenced later from
another function (e.g. this is how scrollbars work). However if I want
to declare a generic variable that is linked to the same scope (e.g.  
set

$name.somevar 1), I cannot figure out how to reference this thing back
from a different scope.

Any ideas?

Best wishes,

Ico


___
Pd-dev mailing list
Pd-dev@iem.at
http://lists.puredata.info/listinfo/pd-dev






Looking at things from a more basic level, you can come up with a more  
direct solution... It may sound small in theory, but it in practice,  
it can change entire economies. - Amy Smith




___
Pd-dev mailing list
Pd-dev@iem.at
http://lists.puredata.info/listinfo/pd-dev


[PD-dev] pd.tk question

2009-10-29 Thread Ivica Ico Bukvic
Hi all,

Is there a way to declare a variable within a proc scope so that it can
be referenced later externally? e.g. having $name.something in
pdtk_canvas_new linked to a widget can be easily referenced later from
another function (e.g. this is how scrollbars work). However if I want
to declare a generic variable that is linked to the same scope (e.g. set
$name.somevar 1), I cannot figure out how to reference this thing back
from a different scope.

Any ideas?

Best wishes,

Ico


___
Pd-dev mailing list
Pd-dev@iem.at
http://lists.puredata.info/listinfo/pd-dev