Page 9 of 30 FirstFirst ... 789101119 ... LastLast
Results 81 to 90 of 297

Thread: "Hello Ubuntu" in every programming language

  1. #81
    Join Date
    Jun 2006
    Beans
    41
    Distro
    Ubuntu 7.04 Feisty Fawn

    Re: "Hello Ubuntu" in every programming language

    PyGTK and Glade:

    HelloUbuntu.glade:
    Code:
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
    <!--Generated with glade3 3.2.0 on Sun Aug  5 16:51:48 2007 by noneofyourbusiness@NowhereYouKnow-->
    <glade-interface>
      <widget class="GtkWindow" id="wndMain">
        <property name="visible">True</property>
        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
        <property name="title" translatable="yes">Welcome to Ubuntu</property>
        <signal name="destroy" handler="on_wndMain_destroy"/>
        <child>
          <widget class="GtkVBox" id="vbox1">
            <property name="visible">True</property>
            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
            <child>
              <widget class="GtkHBox" id="hbox1">
                <property name="visible">True</property>
                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                <child>
                  <widget class="GtkLabel" id="label1">
                    <property name="visible">True</property>
                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                    <property name="xpad">13</property>
                    <property name="ypad">5</property>
                    <property name="label" translatable="yes">What is your name?
    </property>
                  </widget>
                  <packing>
                    <property name="expand">False</property>
                    <property name="fill">False</property>
                    <property name="padding">17</property>
                  </packing>
                </child>
                <child>
                  <widget class="GtkEntry" id="txtName">
                    <property name="visible">True</property>
                    <property name="can_focus">True</property>
                    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                  </widget>
                  <packing>
                    <property name="position">1</property>
                  </packing>
                </child>
              </widget>
            </child>
            <child>
              <widget class="GtkButton" id="btnWelcome">
                <property name="visible">True</property>
                <property name="can_focus">True</property>
                <property name="receives_default">True</property>
                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                <property name="label" translatable="yes">Welcome me!</property>
                <signal name="clicked" handler="on_btnWelcome_clicked"/>
              </widget>
              <packing>
                <property name="position">1</property>
              </packing>
            </child>
            <child>
              <widget class="GtkLabel" id="lblWelcome">
                <property name="visible">True</property>
                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
              </widget>
              <packing>
                <property name="position">2</property>
              </packing>
            </child>
          </widget>
        </child>
      </widget>
    </glade-interface>
    HelloUbuntu.py
    Code:
    #!/usr/bin/env python
    
    import gtk
    import gnome.ui
    import gtk.glade
    
    #Load the widget tree.
    class HelloUbuntu:
    	def __init__(self):
    		self.wTree = gtk.glade.XML("HelloUbuntu.glade")
    		
    		dic = {"on_wndMain_destroy":self.destroy_signal,"on_btnWelcome_clicked":self.click_signal}
    		self.wTree.signal_autoconnect(dic)
    		
    	def destroy_signal(self,widget):
    		gtk.main_quit()
    		
    	def click_signal(self,widget):
    		name = self.wTree.get_widget("txtName").get_text()
    		self.wTree.get_widget("lblWelcome").set_text("Hello " + name + ", welcome to Ubuntu!")
    		
    if __name__== "__main__":
    	app = HelloUbuntu()
    	gtk.main()
    Put the .glade file in the same directory as the .py file, and then run the python file.

    I've been meaning to get off my butt and learn to use Glade to build PyGTK interfaces. This made me do it, and it took just about twenty minutes to learn!
    Last edited by theturtlemoves; August 5th, 2007 at 10:07 PM. Reason: Accidentally left personal info in my Glade file header.

  2. #82
    Join Date
    May 2006
    Beans
    471

    Re: "Hello Ubuntu" in every programming language

    Quote Originally Posted by s1ightcrazed View Post
    Windows Shell Script

    Code:
    @echo off
    set /P ANSWER="Please enter your name: "
    echo. 
    echo Welcome to Ubuntu, %ANSWER%
    pause
    why would you do that?? ..
    t.t.d.
    Segmentation Fault

  3. #83
    Join Date
    Mar 2007
    Location
    /Earth/USA/MD/Home
    Beans
    826
    Distro
    Ubuntu 7.10 Gutsy Gibbon

    Re: "Hello Ubuntu" in every programming language

    Whitespace (For real):

    The blue is whitespace, not the white. I had to use an image because the forums rejects true whitespace
    Last edited by Nekiruhs; August 6th, 2007 at 08:41 PM.
    In Soviet Russia, cake lies you!
    My Blog | Email Me

  4. #84
    Join Date
    Jul 2007
    Location
    Ottawa, Canada
    Beans
    228
    Distro
    Ubuntu 7.10 Gutsy Gibbon

    Re: "Hello Ubuntu" in every programming language

    COBOL

    IDENTIFICATION DIVISION.
    PROGRAM-ID HELLOUBUNTU
    AUTHOR GUILLY.


    WORKING-STORAGE SECTION.
    NAME PIC X(25).


    PROCEDURE DIVISION.
    PERFORM HELLO-UBUNTU.

    HELLO-UBUNTU.
    DISPLAY 'NAME PLEASE:'
    LINE 5 COLUMN 5.
    ACCEPT NAME
    LINE 6 COLUMN 5.

    DISPLAY 'WELCOME TO UBUNTU,' NAME!.
    LINE 8 COLUMN 5.


    i think thats right :S

  5. #85
    Join Date
    Jul 2007
    Beans
    261
    Distro
    Ubuntu Jaunty Jackalope (testing)

    Re: "Hello Ubuntu" in every programming language

    pascal
    Code:
    program helloubuntu;
    write('helloubuntu');
    readln;
    end.
    is bash like windows batch
    iaaaaaaasoqjdokasjfidsjfi

  6. #86
    Join Date
    Jul 2007
    Beans
    261
    Distro
    Ubuntu Jaunty Jackalope (testing)

    Re: "Hello Ubuntu" in every programming language

    Quote Originally Posted by rbprogrammer View Post
    why would you do that?? ..
    i like windows batch
    iaaaaaaasoqjdokasjfidsjfi

  7. #87
    Join Date
    Dec 2005
    Beans
    527
    Distro
    Ubuntu 7.04 Feisty Fawn

    Re: "Hello Ubuntu" in every programming language

    bash i think might be more capable than bash. Most people prefere Python, Ruby or Perl for quick tasks as it allows for more advanced applications than say... bash.

  8. #88
    Join Date
    May 2006
    Beans
    471

    Re: "Hello Ubuntu" in every programming language

    Quote Originally Posted by Note360 View Post
    bash i think might be more capable than bash. Most people prefere Python, Ruby or Perl for quick tasks as it allows for more advanced applications than say... bash.


    what do you mean?? i think one of those "bash"es might supposed to be "batch"
    t.t.d.
    Segmentation Fault

  9. #89
    Join Date
    Dec 2005
    Beans
    527
    Distro
    Ubuntu 7.04 Feisty Fawn

    Re: "Hello Ubuntu" in every programming language

    oops. yeah the second is supposed to be batch

    bash i think might be more capable than batch. bc im bashign batch.

  10. #90
    Join Date
    Apr 2007
    Beans
    14,781

    Re: "Hello Ubuntu" in every programming language

    Batch is useful, although it is nowhere near the power of Bash. (I use Batch for simple tasks.)

Page 9 of 30 FirstFirst ... 789101119 ... LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •