List Info

Thread: Can't get basic code to work




Can't get basic code to work
country flaguser name
Canada
2007-07-25 14:23:36
Hello,

Sorry if this seems a bit idiotic guys but I can't even get
through the 
basic stuff.

Using MonoDevelop/Stetic, I just have a basic window with a
button, 
label and entry widgets. I have the following attached to
the button 
buttonPressEvent:

    protected virtual void onButtonPress (object o, 
Gtk.ButtonPressEventArgs args)
    {
        label1.Text = "abcd";
        entry1.Text = "1234";
    }

and this attached to the button Activated signal:

    protected virtual void onActivated (object sender,
System.EventArgs e)
    {
        label1.Text = "abcd";
        entry1.Text = "1234";
    }

When I run the app and click on the button, neither one of
these is 
working, the text does not show up in the label or the entry
box. What 
am I missing?


Thanks,
George
_______________________________________________
Monodevelop-list mailing list
Monodevelop-listlists.ximian.com
http://lists.ximian.com/mailman/listinfo/monodevelop-li
st

Re: Can't get basic code to work
country flaguser name
United States
2007-07-25 14:40:38
you probably want button.Clicked event, not Activated

Jeff

On Wed, 2007-07-25 at 12:23 -0700, George Lober wrote:
> Hello,
> 
> Sorry if this seems a bit idiotic guys but I can't even
get through the 
> basic stuff.
> 
> Using MonoDevelop/Stetic, I just have a basic window
with a button, 
> label and entry widgets. I have the following attached
to the button 
> buttonPressEvent:
> 
>     protected virtual void onButtonPress (object o, 
> Gtk.ButtonPressEventArgs args)
>     {
>         label1.Text = "abcd";
>         entry1.Text = "1234";
>     }
> 
> and this attached to the button Activated signal:
> 
>     protected virtual void onActivated (object sender,
System.EventArgs e)
>     {
>         label1.Text = "abcd";
>         entry1.Text = "1234";
>     }
> 
> When I run the app and click on the button, neither one
of these is 
> working, the text does not show up in the label or the
entry box. What 
> am I missing?
> 
> 
> Thanks,
> George
> _______________________________________________
> Monodevelop-list mailing list
> Monodevelop-listlists.ximian.com
> http://lists.ximian.com/mailman/listinfo/monodevelop-li
st

_______________________________________________
Monodevelop-list mailing list
Monodevelop-listlists.ximian.com
http://lists.ximian.com/mailman/listinfo/monodevelop-li
st

Re: Can't get basic code to work
country flaguser name
Mexico
2007-07-25 18:47:50
Looks like the compiler is not aware of the Clicked Signal
and/or the Label & 
Entry widgets. Try the following:

1.- On Stetic you need to initialize the Clicked signal for
the button1. On 
the Stetic designer, select the button on the <Widget
Properties> go to the 
tab <Signals> (There are only two tabs,
<Properties> & <Signals>).  Expand 
<Button Signals> and then select <Clicked>, then
double click to initialize 
the Signal, and again double click to create the template:

protected virtual void OnButton1Clicked(object sender,
System.EventArgs e){ }

On MainWindow.cs in the view Source Code (MainWindow.cs have
two view <Source 
Code> & <Designer>). Here you can start coding.

2.- Probably you are not declaring the label1 & entry1
widgets. So you need to 
declare them as Gtk widgets right after the declaration of
the public class 
and before the constructor:

public class MainWindow: Gtk.Window
{       
        Label label1; // or Gtk.Label 
        Entry entry1; // or Gtk.Entry
        public MainWindow (): base ("")
        {

On Wednesday 25 July 2007 17:27:27 Sergio Hernandez wrote:
> Looks like the compiler is not aware of the Clicked
Signal and/or the Label
> & Entry widgets. Try the following:
>
> 1.- On Stetic you need to initialize the Clicked signal
for the button1. On
> the Stetic designer, select the button on the
<Widget Properties> go to the
> tab <Signals> (There are only two tabs,
<Properties> & <Signals>).  Expand
> <Button Signals> and then select <Clicked>,
then double click to initialize
> the Signal, and again double click to create the
template:
>
> protected virtual void OnButton1Clicked(object sender,
System.EventArgs e){
> }
>
> On MainWindow.cs in the view Source Code (MainWindow.cs
have two view
> <Source Code> & <Designer>). Here you
can start coding.
>
> 2.- Probably you are not declaring the label1 &
entry1 widgets. So you need
> to declare them as Gtk widgets right after the
declaration of the public
> class and before the constructor:
>
> public class MainWindow: Gtk.Window
> {       
>         Label label1; // or Gtk.Label
>         Entry entry1; // or Gtk.Entry
>         public MainWindow (): base
("")
>         {


_______________________________________________
Monodevelop-list mailing list
Monodevelop-listlists.ximian.com
http://lists.ximian.com/mailman/listinfo/monodevelop-li
st
Re: Can't get basic code to work
country flaguser name
Mexico
2007-07-25 18:48:39
By the way, probably you want to try this so you clearly
understand the order 
the events/signal occurs:

        protected virtual void OnButton1Clicked(object
sender, 
System.EventArgs e){
                label1.Text = "Clicked";
                entry1.Text = "Clicked";}

        protected virtual void OnButton1Activated(object
sender, 
System.EventArgs e){
                label1.Text = "Activated";
                entry1.Text = "Activated";}

        protected virtual void OnButton1Entered(object
sender, 
System.EventArgs e){
                label1.Text = "Entered";
                entry1.Text = "Entered";}

        protected virtual void OnButton1Pressed(object
sender, 
System.EventArgs e){
                label1.Text = "Pressed";
                entry1.Text = "Pressed";}

        protected virtual void OnButton1Released(object
sender, 
System.EventArgs e){
                label1.Text = "Released";
                entry1.Text = "Released";}

        protected virtual void OnButton1Left(object sender,
System.EventArgs 
e){
                label1.Text = "Left";
                entry1.Text = "Left";}

And don't forget to initialice the all the signals on
Stetic.


On Wednesday 25 July 2007 17:33:06 Sergio Hernandez wrote:
> By the way, probably you want to try this so you
clearly understand the
> order the events/signal occurs:
>
>         protected virtual void OnButton1Clicked(object
sender,
> System.EventArgs e){ label1.Text =
"Clicked";
>                 entry1.Text = "Clicked";}
>
>         protected virtual void
OnButton1Activated(object sender,
> System.EventArgs e){ label1.Text =
"Activated";
>                 entry1.Text = "Activated";}
>
>         protected virtual void OnButton1Entered(object
sender,
> System.EventArgs e){ label1.Text =
"Entered";
>                 entry1.Text = "Entered";}
>
>         protected virtual void OnButton1Pressed(object
sender,
> System.EventArgs e){ label1.Text =
"Pressed";
>                 entry1.Text = "Pressed";}
>
>         protected virtual void OnButton1Released(object
sender,
> System.EventArgs e){ label1.Text =
"Released";
>                 entry1.Text = "Released";}
>
>         protected virtual void OnButton1Left(object
sender,
> System.EventArgs e){ label1.Text = "Left";
>                 entry1.Text = "Left";}
>
> And don't forget to initialice the all the signals on
Stetic.


_______________________________________________
Monodevelop-list mailing list
Monodevelop-listlists.ximian.com
http://lists.ximian.com/mailman/listinfo/monodevelop-li
st

Re: Can't get basic code to work
country flaguser name
Canada
2007-07-25 21:55:46
Looks like the problem was with using the right signal.
Using the 
Clicked event and my original steps is working now. One
thing that I was 
doing which is different from the steps that you outline is
that I was 
entering the event name manually in the signals column (the
fields do 
say to "Click here to add a new handler") as
opposed to double clicking 
twice on the signal name itself, but this does not appear to
make a 
difference, it is the Clicked signal that was needed. I do
prefer the 
double click approach thou, so thank you for pointing that
out.


Thank you for your help,
George



Sergio Hernandez wrote:
>
> Looks like the compiler is not aware of the Clicked
Signal and/or the 
> Label & Entry widgets. Try the following:
>
> 1.- On Stetic you need to initialize the Clicked signal
for the 
> button1. On the Stetic designer, select the button on
the <Widget 
> Properties> go to the tab <Signals> (There are
only two tabs, 
> <Properties> & <Signals>). Expand
<Button Signals> and then select 
> <Clicked>, then double click to initialize the
Signal, and again 
> double click to create the template:
>
> protected virtual void OnButton1Clicked(object sender,

> System.EventArgs e){ }
>
> On MainWindow.cs in the view Source Code (MainWindow.cs
have two view 
> <Source Code> & <Designer>). Here you
can start coding.
>
> 2.- Probably you are not declaring the label1 &
entry1 widgets. So you 
> need to declare them as Gtk widgets right after the
declaration of the 
> public class and before the constructor:
>
> public class MainWindow: Gtk.Window
>
> {
>
> Label label1; // or Gtk.Label
>
> Entry entry1; // or Gtk.Entry
>
> public MainWindow (): base ("")
>
> {
>
> On Wednesday 25 July 2007 13:23:36 George Lober wrote:
>
> > Hello,
>
> >
>
> > Sorry if this seems a bit idiotic guys but I can't
even get through the
>
> > basic stuff.
>
> >
>
> > Using MonoDevelop/Stetic, I just have a basic
window with a button,
>
> > label and entry widgets. I have the following
attached to the button
>
> > buttonPressEvent:
>
> >
>
> > protected virtual void onButtonPress (object o,
>
> > Gtk.ButtonPressEventArgs args)
>
> > {
>
> > label1.Text = "abcd";
>
> > entry1.Text = "1234";
>
> > }
>
> >
>
> > and this attached to the button Activated signal:
>
> >
>
> > protected virtual void onActivated (object sender,
System.EventArgs e)
>
> > {
>
> > label1.Text = "abcd";
>
> > entry1.Text = "1234";
>
> > }
>
> >
>
> > When I run the app and click on the button,
neither one of these is
>
> > working, the text does not show up in the label or
the entry box. What
>
> > am I missing?
>
> >
>
> >
>
> > Thanks,
>
> > George
>
> > _______________________________________________
>
> > Monodevelop-list mailing list
>
> > Monodevelop-listlists.ximian.com
>
> > http://lists.ximian.com/mailman/listinfo/monodevelop-li
st
>

_______________________________________________
Monodevelop-list mailing list
Monodevelop-listlists.ximian.com
http://lists.ximian.com/mailman/listinfo/monodevelop-li
st

Re: Can't get basic code to work
country flaguser name
Canada
2007-07-25 21:58:32
Sergio Hernandez wrote:
> By the way, probably you want to try this so you
clearly understand the order 
> the events/signal occurs:
>
> 	protected virtual void OnButton1Clicked(object sender,
System.EventArgs e){
> 		label1.Text = "Clicked";
> 		entry1.Text = "Clicked";}
>
> 	protected virtual void OnButton1Activated(object
sender, System.EventArgs e){
> 		label1.Text = "Activated";
> 		entry1.Text = "Activated";}
>
> 	protected virtual void OnButton1Entered(object sender,
System.EventArgs e){
> 		label1.Text = "Entered";
> 		entry1.Text = "Entered";}
>
> 	protected virtual void OnButton1Pressed(object sender,
System.EventArgs e){
> 		label1.Text = "Pressed";
> 		entry1.Text = "Pressed";}
>
> 	protected virtual void OnButton1Released(object
sender, System.EventArgs e){
> 		label1.Text = "Released";
> 		entry1.Text = "Released";}
>
> 	protected virtual void OnButton1Left(object sender,
System.EventArgs e){
> 		label1.Text = "Left";
> 		entry1.Text = "Left";}
>
> And don't forget to initialice the all the signals on
Stetic.
>   

Good suggestion.  As luck would have it, the two that I
chose 
(ButtonPressEvent and Activated) don't seem to do much.

One signal/event which I'm trying to find is the equivalent
of the 
delphi form onCreate event (when a window is created). Would
this be the 
"Realized" signal ? I would need this to put
one-time run start-up code 
into.


Thank you,
George

_______________________________________________
Monodevelop-list mailing list
Monodevelop-listlists.ximian.com
http://lists.ximian.com/mailman/listinfo/monodevelop-li
st

Re: Can't get basic code to work
user name
2007-07-25 22:19:41


On 7/25/07, George Lober < georgeloberglowsoftware.ca">georgeloberglowsoftware.ca> wrote:
Sergio Hernandez wrote:
>; By the way, probably you want to try this so you clearly understand the order
> the events/signal occurs:
&gt;
>&nbsp; &nbsp; &nbsp;  protected virtual void OnButton1Clicked(object sender, System.EventArgs e){
>&nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp; label1.Text = "Clicked";
> &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;  entry1.Text = "Clicked";}
>
>&nbsp;   ; &nbsp; protected virtual void OnButton1Activated(object sender, System.EventArgs e){
>&nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp; label1.Text = "Activated";
; &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; entry1.Text = "Activated";}
>
>; &nbsp; &nbsp; &nbsp; protected virtual void OnButton1Entered(object sender, System.EventArgs e){
>  ; &nbsp; &nbsp; &nbsp; &nbsp;   ;  label1.Text = "Entered";
> &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;  entry1.Text = "Entered";}
>
>&nbsp;   ; &nbsp; protected virtual void OnButton1Pressed(object sender, System.EventArgs e){
>&nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp; label1.Text = "Pressed";
> &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;  entry1.Text = "Pressed";}
>
>&nbsp;   ; &nbsp; protected virtual void OnButton1Released(object sender, System.EventArgs e){
>&nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp; label1.Text = "Released";
  ; &nbsp; &nbsp; &nbsp; &nbsp;   ; entry1.Text = "Released";}
>
>  ; &nbsp; &nbsp; protected virtual void OnButton1Left(object sender, System.EventArgs e){
>&nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp; label1.Text = "Left";
&gt; &nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp;  entry1.Text = "Left";}
&gt;
> And don't forget to initialice the all the signals on Stetic.
&gt;

Good suggestion. &nbsp;As luck would have it, the two that I chose
(ButtonPressEvent and Activated) don't seem to do much.

One signal/event which I'm trying to find is the equivalent of the
delphi form onCreate event (when a window is created). Would this be the
"Realized&quot; signal ? I would need this to put one-time run start-up code
into.

Why not use the class' constructor?
 

Thank you,
George

_______________________________________________
Monodevelop-list mailing list
Monodevelop-listlists.ximian.com">Monodevelop-listlists.ximian.com
http://lists.ximian.com/mailman/listinfo/monodevelop-list

Re: Can't get basic code to work
country flaguser name
Canada
2007-07-26 20:47:28
Marcos Marín wrote:
>
>     One signal/event which I'm trying to find is the
equivalent of the
>     delphi form onCreate event (when a window is
created). Would this
>     be the
>     "Realized" signal ? I would need this to
put one-time run start-up
>     code
>     into.
>
>
> Why not use the class' constructor?
>  

Would you mean inside of the "public partial class
MainWindow: 
Gtk.Window" block in MainWindow.cs ?

_______________________________________________
Monodevelop-list mailing list
Monodevelop-listlists.ximian.com
http://lists.ximian.com/mailman/listinfo/monodevelop-li
st

Re: Can't get basic code to work
user name
2007-07-26 23:10:12
On 7/26/07, George Lober <georgeloberglowsoftware.ca> wrote:
> Marcos Marín wrote:
> >
> >     One signal/event which I'm trying to find is
the equivalent of the
> >     delphi form onCreate event (when a window is
created). Would this
> >     be the
> >     "Realized" signal ? I would need
this to put one-time run start-up
> >     code
> >     into.
> >
> >
> > Why not use the class' constructor?
> >
>
> Would you mean inside of the "public partial class
MainWindow:
> Gtk.Window" block in MainWindow.cs ?

Yes.  Within that block (ie, within the class), you want to
add a
constructor.  If this term is new to you you'll want to find
a book or
tutorial on C#, but basically it's a method called when your
class
(your window in this case) is first created, and it usually
looks like
this:

public MainWindow ()
{
   // Do initialization stuff here
}

Hope this helps,
Sandy
_______________________________________________
Monodevelop-list mailing list
Monodevelop-listlists.ximian.com
http://lists.ximian.com/mailman/listinfo/monodevelop-li
st

Re: Can't get basic code to work
user name
2007-07-27 08:20:25
If that code will take a long time to be executed you can
start it in
a thread, and after the tread ends, update the controls (you
can't
update from another thread).

If the time it needs is small, you can just do it in the
constructor,
even before the window is shown, or first forcing it to show
and then
running the piece of code. It is important to know that if
the code
depends on the existence of the controls, it should be
called after
the code Stetic generates is called.

Fun,

On 7/26/07, George Lober <georgeloberglowsoftware.ca> wrote:
> Marcos Marín wrote:
> >
> >     One signal/event which I'm trying to find is
the equivalent of the
> >     delphi form onCreate event (when a window is
created). Would this
> >     be the
> >     "Realized" signal ? I would need
this to put one-time run start-up
> >     code
> >     into.
> >
> >
> > Why not use the class' constructor?
> >
>
> Would you mean inside of the "public partial class
MainWindow:
> Gtk.Window" block in MainWindow.cs ?
>
> _______________________________________________
> Monodevelop-list mailing list
> Monodevelop-listlists.ximian.com
> http://lists.ximian.com/mailman/listinfo/monodevelop-li
st
>


-- 
Rafael "Monoman" Teixeira
---------------------------------------
"I myself am made entirely of flaws, stitched together
with good intentions."
Augusten Burroughs
_______________________________________________
Monodevelop-list mailing list
Monodevelop-listlists.ximian.com
http://lists.ximian.com/mailman/listinfo/monodevelop-li
st
[1-10]

about | contact  Other archives ( Real Estate discussion Medical topics )