I’m considering using the FOX toolkit in a project instead of Ruby/Tk, but I don’t see anything in FOX equivalent to Ruby/Tk’s TkText widget. I basically need an editable widget that will allow me to set the font, color, boldness, etc. of specific regions of text. Does such a thing exist?
Bill Atkins wrote:
I’m considering using the FOX toolkit in a project instead of Ruby/Tk, but I don’t see anything in FOX equivalent to Ruby/Tk’s TkText widget. I basically need an editable widget that will allow me to set the font, color, boldness, etc. of specific regions of text. Does such a thing exist?
See examples/styledtext.rb. To make it editable, just add the line
text.editable = true
Hello Bill,
Thursday, March 18, 2004, 9:10:11 PM, you wrote:
I'm considering using the FOX toolkit in a project instead of
Ruby/Tk, but I don't see anything in FOX equivalent to Ruby/Tk's
TkText widget. I basically need an editable widget that will
allow me to set the font, color, boldness, etc. of specific
regions of text. Does such a thing exist?
No it does not exist. You can use the FXText class to show different
colors, but not different fonts.
Maybe you like to port the TkText to FOX
···
--
Best regards,
Lothar mailto:mailinglists@scriptolutions.com
The GTK+2 text widget is just like the Tk widget, with tags, marks,
gravity, etc.
···
On Fri, 19 Mar 2004 05:10:11 +0900 “Bill Atkins” batkins57@myway.com wrote:
I’m considering using the FOX toolkit in a project instead of Ruby/Tk,
but I don’t see anything in FOX equivalent to Ruby/Tk’s TkText widget.
I basically need an editable widget that will allow me to set the
font, color, boldness, etc. of specific regions of text. Does such a
thing exist?
–
“Don’t you see that the whole aim of Newspeak is to narrow the range of
thought? In the end we shall make thoughtcrime literally impossible,
because there will be no words in which to express it.”
– George Orwell as Syme in “1984”
Bill Atkins wrote:
I basically need an editable widget that will allow me to set the font, color, boldness, etc. of specific regions of text. Does such a thing exist?
As Joel and Lothar reported, you can use FOX’s FXText widget to do some
very limited text styling (maybe just colored text?) but that’s all. If
you need more than that you can also take a look at the FXScintilla
widget (a port of Scintilla to FOX).
Hi
I am trying to implement a class which is cacheable. New instances are created if they are not already in cache.
what is the best way?
redefining new should be a good idea?
rolo
Hello Albert,
Friday, March 19, 2004, 12:59:32 AM, you wrote:
···
On Fri, 19 Mar 2004 05:10:11 +0900 > "Bill Atkins" <batkins57@myway.com> wrote:
I'm considering using the FOX toolkit in a project instead of Ruby/Tk,
but I don't see anything in FOX equivalent to Ruby/Tk's TkText widget.
I basically need an editable widget that will allow me to set the
font, color, boldness, etc. of specific regions of text. Does such a
thing exist?
The GTK+2 text widget is just like the Tk widget, with tags, marks,
gravity, etc.
No, it is the Tk widget, ported to GTK.
--
Best regards,
Lothar mailto:mailinglists@scriptolutions.com
Hi –
Hi
I am trying to implement a class which is cacheable. New instances
are created if they are not already in cache. what is the best way?
I’m not sure what you mean. If an instance has already been created,
it’s not going to be created again (whether it’s in a cache or not).
redefining new should be a good idea?
Probably not. But can you describe the problem in more detail?
David
rolo wrote:
Hi
I am trying to implement a class which is cacheable. New instances are created if they are not already in cache.
what is the best way?
Easy.
redefining new should be a good idea?
That, or you can define a define a different class method, which calls new:
class Thing
@cache = {}
def self.instance(name)
@cache[name] ||= new(name)
end
def initialize(name)
@name = name
end
end
t1 = Thing.instance “t”
t2 = Thing.instance “t”
p t1.id
p t2.id
Even better. It is more alike than I thought
···
On Fri, 19 Mar 2004 12:37:24 +0900 Lothar Scholz mailinglists@scriptolutions.com wrote:
–
“Don’t you see that the whole aim of Newspeak is to narrow the range of
thought? In the end we shall make thoughtcrime literally impossible,
because there will be no words in which to express it.”
– George Orwell as Syme in “1984”
class Thing
@cache = {}
def self.instance(name)
@cache[name] ||= new(name)
end
def initialize(name)
@name = name
end
end
t1 = Thing.instance "t"
t2 = Thing.instance “t”
[rolo] mysterious. it works! but since cache is an instance level variable how is it shared amongst all the class instances?
rolo
rolo wrote:
class Thing
@cache = {}
def self.instance(name)
@cache[name] ||= new(name)
end
def initialize(name)
@name = name
end
endt1 = Thing.instance “t”
t2 = Thing.instance “t”p t1.id
p t2.id[rolo] mysterious. it works! but since cache is an instance level variable how is it shared amongst all the class instances?
@cache is an instance variable of the class Object called Thing. It’s
just a regular instance variable, but it happens to be stored in a class
object instead of in instances of the class. Instances of Thing can’t
access it directly.
rolo wrote:
class Thing
@cache = {}
def self.instance(name)
@cache[name] ||= new(name)
end
def initialize(name)
@name = name
end
endt1 = Thing.instance “t”
t2 = Thing.instance “t”p t1.id
p t2.id[rolo] mysterious. it works! but since cache is an instance level variable how is it shared amongst all the class instances?
@cache is an instance variable of the class Object called Thing. It’s
just a regular instance variable, but it happens to be stored in a class
object instead of in instances of the class. Instances of Thing can’t
access it directly.
[rolo] should it not be @@cache ?
···
-----Original Message-----
From: Joel VanderWerf [mailto:vjoel@PATH.Berkeley.EDU]
Sent: Friday, April 09, 2004 11:58 PM
To: ruby-talk ML
Subject: Re: Cache of objects
Hi –
···
On Sat, 10 Apr 2004, rolo wrote:
-----Original Message-----
From: Joel VanderWerf [mailto:vjoel@PATH.Berkeley.EDU]
Sent: Friday, April 09, 2004 11:58 PM
To: ruby-talk ML
Subject: Re: Cache of objectsrolo wrote:
class Thing
@cache = {}
def self.instance(name)
@cache[name] ||= new(name)
end
def initialize(name)
@name = name
end
endt1 = Thing.instance “t”
t2 = Thing.instance “t”p t1.id
p t2.id[rolo] mysterious. it works! but since cache is an instance level variable how is it shared amongst all the class instances?
@cache is an instance variable of the class Object called Thing. It’s
just a regular instance variable, but it happens to be stored in a class
object instead of in instances of the class. Instances of Thing can’t
access it directly.[rolo] should it not be @@cache ?
No, that’s a class variable, which is different from an instance
variable of a Class object. In spite of the shared use of ‘@’,
they’re separate and different things.
David
–
David A. Black
dblack@wobblini.net
class Thing
@cache = {}
def self.instance(name)
@cache[name] ||= new(name)
end
def initialize(name)
@name = name
end
endt1 = Thing.instance “t”
t2 = Thing.instance “t”p t1.id
p t2.id[rolo] mysterious. it works! but since cache is an instance level variable how is it shared amongst all the class instances?
@cache is an instance variable of the class Object called Thing. It’s
just a regular instance variable, but it happens to be stored in a class
object instead of in instances of the class. Instances of Thing can’t
access it directly.[rolo] should it not be @@cache ?
No, that’s a class variable, which is different from an instance
variable of a Class object. In spite of the shared use of ‘@’,
they’re separate and different things.
[rolo] There are 2 things here. one Thing object and other t1 object.
@cache is a variable that belongs to Thing or t1?
rolo
rolo wrote:
class Thing
@cache = {}
def self.instance(name)
@cache[name] ||= new(name)
end
def initialize(name)
@name = name
end
end[rolo] There are 2 things here. one Thing object and other t1 object.
@cache is a variable that belongs to Thing or t1?
@cache belongs to the Thing object. Notice that is is defined in the
class definition of Thing without being nested in a method definition.
And it is referenced in a class method (def self.instance).
···
–
– Jim Weirich jim@weirichhouse.org http://onestepback.org
“Beware of bugs in the above code; I have only proved it correct,
not tried it.” – Donald Knuth (in a memo to Peter van Emde Boas)
rolo wrote:
class Thing
@cache = {}
def self.instance(name)
@cache[name] ||= new(name)
end
def initialize(name)
@name = name
end
endt1 = Thing.instance “t”
t2 = Thing.instance “t”p t1.id
p t2.id[rolo] mysterious. it works! but since cache is an instance level variable how is it shared amongst all the class instances?
@cache is an instance variable of the class Object called Thing. It’s
just a regular instance variable, but it happens to be stored in a class
object instead of in instances of the class. Instances of Thing can’t
access it directly.[rolo] should it not be @@cache ?
No, that’s a class variable, which is different from an instance
variable of a Class object. In spite of the shared use of ‘@’,
they’re separate and different things.[rolo] There are 2 things here. one Thing object and other t1 object.
@cache is a variable that belongs to Thing or t1?
Thing is an instance of Class.
t1 is an instance of Thing.
@cash belongs to Thing and is not visible to t1 (on a side none, @@cash
would be visible to all instances of Thing, to t1 in particular).
Gennady.
···
rolo