SlideShare une entreprise Scribd logo
1  sur  18
Télécharger pour lire hors ligne
A Exercise on Interdependent select (or chained select) using
ComboBoxEntry in Glade3 And Ruby


Core:

        w are going to develop chained selection module using comboboxentry .

      In first comboboxentry, will list out countries names, when user select any one of
countries from this list, application will display another dependent comboboxentry.

       The second comboboxentry have to list out “states” which are all corresponding to
selected country in first comboboxentry box.

        Then it will be displayed , third comboboxentry & it will list out cities corresponding
to the selected state in second comboboxentry box.


How to install ruby :

 $sudo apt-get install ruby


How to install glade :

 $sudo apt-get install glade

Or goto 'synaptic package mamager' and find glade3, select mark for installation and click
'Apply' button.


ruby-glade-create-template command :

To run this command we have to install ruby package,

 $sudo apt-get install libglade2-ruby



How to install active-record :

 $sudo apt-get install rubygems

 $sudo gem install activerecord


Error :

While installing activerecord , it will show following error:
usr/bin/gem:10: undefined method `manage_gems' for Gem:Module (NoMethodError)

For that do the following:

 $sudo gedit /usr/bin/gem

 add the following two lines in top of the coding :

 require 'rubygems'
 require 'rubygems/gem_runner'

 and comment the next line by

 #Gem.manage_gems


Glade Guide

   1).   Drag and drop “Window” from Top Level Window
   2).   Place “Fixed Layer” from Container in window
   3).   Take three “ComboBoxEntry” and place in window.
   4).   Set lable name to each comboboxentry and comboboxentry-entry1 to identify.

         Signal:

            set “changed “ signal to all comboboxentry widget. And save it as
“combo.glade”


                       Open Glade3 from Programming Application
Opened Glade Window




Select Window Widget and drop in design area
Drag and drop “fixed” widget and plce inside toplevel window




                Take comboboxentry
Change your comboboxentry widget label name to identify




    Allign and customize comboboxentry widget box size
Set 'change siganl' to all comboboxentry from the “Signal”menu side panel
Drag and drop the 'Label' widget & change label name & allign it.




                     Final design view
Ruby Guide

       $ ruby-glade-create-template combo.glade > combo.rb



       Initialize Method :


       Add one line inside initialize method as follow .

       @glade[“Window1”].show_all


      “Window1” is a default lable name of top level window. If u want change that lable
name...




Program :

# Active Record


require 'libglade2'
require 'rubygems'
require 'active_record'
ActiveRecord::Base.logger = Logger.new(STDERR)
ActiveRecord::Base.colorize_logging = false

ActiveRecord::Base.establish_connection(
  :adapter => quot;mysqlquot;,
  :encoding => quot;utf8quot;,
  :database => quot;countryquot;,
  :username => quot;rootquot;,
  :password =>quot;passwordquot;,
  :socket => quot;/var/run/mysqld/mysqld.sockquot;,
  :dbfile => quot;:memory:quot;
)

ActiveRecord::Schema.define do
  create_table :countries do |table|
    table.column :name, :string
  end
create_table :states do |table|
    table.column :country_id, :integer
    table.column :name, :string
  end

  create_table :cities do |table|
    table.column :state_id, :integer
    table.column :name, :string

  end

end



=begin

create database “ country” in your mysql by excuting this query
 “mysql > create database country; “.

And set your mysql root user name “root” and “password” in the above code.


You can understand easily by seeing the above code, how active record creates tables and
corresponding fields.

Create_table: 'table name' - - - > It will create table in db.
Column: name, :String ( Field Type) - - -> It will set column field by this type and name.

=end

# Relationships :


class Country < ActiveRecord::Base
   has_many :state
end

class State < ActiveRecord::Base
   belongs_to :country
   has_many :cities
end

class City < ActiveRecord::Base
  belongs_to :state
end


=begin

This tells about relationships among those tables...
“Country “ table record entries having relationship with so many “State” table record
entries...
simply we can represent by one to many relationship, so in this case we have used “
has_many ”. This means a country “has_many” states.

“State” table record entries having relations under “Country” table record entries.... It can
be represented by “ belongs_to “. Since every state belongs to a country hence we have used
“belongs_to” in the state class to say that it belongs to a country.

=end

# Populating values into tables :

country=Country.new(:name=>'India')
country.save

# here we are inserting value 'India' into country table


country.state << State.new(:name => 'TamilNadu')

# it will insert value 'TamilNadu' into state table with country_id


country.state.find(:all,:conditions => {:name => 'TamilNadu'}).first.cities << City.new(:name
=>'Chennai')

# it will append the new entries ' Chennai ' in “city” table with 'Country_id' and ' State_id' .



country=Country.new(:name=>'America')
country.save
country.state << State.new(:name => 'Ohio')
country.state.find(:all,:conditions => {:name => 'Ohio'}).first.cities << City.new(:name
=>'Chicago')

# Like wise, you can insert values into three tables as your wish
# and insert more country, states and city names in corresponding tables . . .




class ComboCountryGlade
 include GetText

 attr :glade

 def initialize(path_or_data, root = nil, domain = nil, localedir = nil, flag = GladeXML::FILE)
  bindtextdomain(domain, localedir, nil, quot;UTF-8quot;)
  @glade = GladeXML.new(path_or_data, root, domain, localedir, flag) {|handler|
method(handler)}
@glade['window1'].show_all

  country_combo _method

 end

# ComboBoxEntry Methods


# country method :

def country_combo_method
       @glade[quot;country_comboboxentryquot;].show_all
       @glade[quot;state_comboboxentryquot;].hide_all
       @glade[quot;State_labelquot;].hide_all
       @glade[quot;city_comboboxentryquot;].hide_all
       @glade[quot;City_labelquot;].hide_all

        # here, we are hiding state and city comboboxentry and their lables

        @country_combobox = @glade[quot;country_comboboxentryquot;]
        @country_list = Gtk::ListStore.new(String)
        @country_cell = Gtk::CellRendererText.new()

         # here, we are setting comboboxentry properties to box by calling inbuild Gtk methods

        @country_combobox.pack_start(@country_cell, true)
        @country_combobox.add_attribute(@country_cell, 'text',0)
        @country_combobox.set_model(@country_list)

        @country=Country.all

        # here, we calling active record class.
        # [Country.all] ---> it will return all countries entries


               @country.each do |country_name|
                @country_iter =@country_list.append
                @country_iter[0] =country_name.name
            end
end


=begin
  here, c_name is iterative variable of @country array record.
 From that, we need “ country name field alone”, so that we use [c_name.name] ----> it will
return countries name.

       [@c_list_cat.append] -----> it will helps to append strings in comboboxentry.
=end
# ComboBoxEntry change signal code : for country


def on_country_comboboxentry_changed(widget)
       @country_click_iter= @glade['country_comboboxentry'].active_iter
       @country_list.each do |model,path,@iter_country|
          if path.to_s == @country_click_iter.to_s
             @glade['country_comboboxentry-entry1'].text =@iter_country[0]
             country_name=@glade['country_comboboxentry-entry1'].text
             @state_combo = @glade[quot;state_comboboxentryquot;]
             @state_combo.clear
              state_combo_method(country_name)
        end
      end

 end


=begin

active_iter : return , pointer of comboboxentry list by corresponding to mouse or keyboard
press on list.

path.to_s : to identify TreeView path of combobox entry.


state_combo(country_name) : Iside country change signal method, we are going to call “
State Comboboxentry and passing argument as country name, which is selected by user at
run time.

same like this logic we have to write code for state and city comboboxentries also .

=end



# State mathod :


def state_combo_method(country_name)
       @glade[quot;state_comboboxentryquot;].show_all
       @glade[quot;State_labelquot;].show_all
       @glade[quot;city_comboboxentryquot;].hide_all
       @glade[quot;City_labelquot;].hide_all

         @state_combobox = @glade[quot;state_comboboxentryquot;]
         @state_list = Gtk::ListStore.new(String)
         @state_cell = Gtk::CellRendererText.new()
         @glade['state_comboboxentry-entry2'].text=quot;quot;
@state_combobox.pack_start(@state_cell, true)
        @state_combobox.add_attribute(@state_cell, 'text',0)
        @state_combobox.set_model(@state_list)


        country1=Country.find(:all,:conditions=>{:name=>country_name}).first.state


        country1.each do |state_name|
               @state_iter =@state_list.append
               @state_iter[0] =state_name.name
      end

end




# ComboBoxEntry change signal code : for state


def on_state_comboboxentry_changed(widget)

        state_click_iter= @glade['state_comboboxentry'].active_iter
         @state_list.each do |model,path,@iter_state|
              if path.to_s == state_click_iter.to_s
                 @glade['state_comboboxentry-entry2'].text =@iter_state[0]
                  state_name= @glade['state_comboboxentry-entry2'].text
                    @city_combo=@glade[quot;city_comboboxentryquot;]
                    @city_combo.clear
                   city_combo_method( state_name)
               end
       end
 end

end



# city method :


def city_combo_method(state_name)
       @glade[quot;city_comboboxentryquot;].show_all
       @glade[quot;City_labelquot;].show_all

        @city_combo = @glade[quot;city_comboboxentryquot;]
        @city_list = Gtk::ListStore.new(String)
        @city_cell = Gtk::CellRendererText.new()
        @glade['city_comboboxentry-entry3'].text=quot;quot;
        @city_combo.pack_start(@city_cell, true)
@city_combo.add_attribute(@city_cell, 'text',0)
         @city_combo.set_model(@city_list)

         city=State.all(:conditions=>{:name=>state_name}).first.cities

         city.each do |city_name|
                 @city_iter =@city_list.append
                  @city_iter[0] =city_name.name
          end
 end


# ComboBoxEntry change signal code : for city


 def on_city_comboboxentry_changed(widget)
       @city_click_iter= @glade['city_comboboxentry'].active_iter
       @city_list.each do |model,path,@iter_city|
            if path.to_s == @city_click_iter.to_s
                @glade['city_comboboxentry-entry3'].text =@iter_city[0]
            end
    end
 end



# Main program for glade
if __FILE__ == $0
  # Set values as your own application.
  PROG_PATH = quot;combo_country.gladequot;
  PROG_NAME = quot;YOUR_APPLICATION_NAMEquot;
  ComboCountryGlade.new(PROG_PATH, nil, PROG_NAME)
  Gtk.main
end

# End of program



=begin

Save the whole program as combo.rb


And then run this program in terminal.

$ruby combo.rb

while running this combo.rb , combo.glade file must contain in the same folder.

=end
Output window :1




Output window : 2




Output window : 3
Output window : 4




Output window : 5




Output window : 6
Output window : 7




Use :

 Using this Chained Selection program , we are developing a school management application
with following scenerio .

 first select one 'class' from class_combobox_entry and then choose 'section' from
section_combobox_entry and then finally select 'student name' from
student_combobox_entry.


You can download this source code from : http://gist.github.com/127848

http://comboboxentry-glade-ruby.blogspot.com/
Enjoy with Ruby and Glade .


Best wishes from Arulalan.T

Contenu connexe

Tendances

$$$ +$$+$$ _+_$+$$_$+$$$_+$$_$
$$$ +$$+$$ _+_$+$$_$+$$$_+$$_$$$$ +$$+$$ _+_$+$$_$+$$$_+$$_$
$$$ +$$+$$ _+_$+$$_$+$$$_+$$_$UltraUploader
 
Stay with React.js in 2020
Stay with React.js in 2020Stay with React.js in 2020
Stay with React.js in 2020Jerry Liao
 
Transformations - how Oracle rewrites your statements
Transformations - how Oracle rewrites your statementsTransformations - how Oracle rewrites your statements
Transformations - how Oracle rewrites your statementsSage Computing Services
 
Indexing thousands of writes per second with redis
Indexing thousands of writes per second with redisIndexing thousands of writes per second with redis
Indexing thousands of writes per second with redispauldix
 
DRUPAL 8 STORAGES OVERVIEW
DRUPAL 8 STORAGES OVERVIEWDRUPAL 8 STORAGES OVERVIEW
DRUPAL 8 STORAGES OVERVIEWDrupalCamp Kyiv
 
Regexes and-performance-testing
Regexes and-performance-testingRegexes and-performance-testing
Regexes and-performance-testingdoughellmann
 
Data20161007
Data20161007Data20161007
Data20161007capegmail
 
JDD 2013 JavaFX
JDD 2013 JavaFXJDD 2013 JavaFX
JDD 2013 JavaFX益裕 張
 
ZFConf 2010: Zend Framework & MVC, Model Implementation (Part 2, Dependency I...
ZFConf 2010: Zend Framework & MVC, Model Implementation (Part 2, Dependency I...ZFConf 2010: Zend Framework & MVC, Model Implementation (Part 2, Dependency I...
ZFConf 2010: Zend Framework & MVC, Model Implementation (Part 2, Dependency I...ZFConf Conference
 
CS 542 Overview of query processing
CS 542 Overview of query processingCS 542 Overview of query processing
CS 542 Overview of query processingJ Singh
 
Frank Rodenbaugh Portfolio
Frank Rodenbaugh PortfolioFrank Rodenbaugh Portfolio
Frank Rodenbaugh PortfolioFrankRodenbaugh
 
Task 2
Task 2Task 2
Task 2EdiPHP
 
Hacking Your Way To Better Security - Dutch PHP Conference 2016
Hacking Your Way To Better Security - Dutch PHP Conference 2016Hacking Your Way To Better Security - Dutch PHP Conference 2016
Hacking Your Way To Better Security - Dutch PHP Conference 2016Colin O'Dell
 
Type safe embedded domain-specific languages
Type safe embedded domain-specific languagesType safe embedded domain-specific languages
Type safe embedded domain-specific languagesArthur Xavier
 

Tendances (20)

$$$ +$$+$$ _+_$+$$_$+$$$_+$$_$
$$$ +$$+$$ _+_$+$$_$+$$$_+$$_$$$$ +$$+$$ _+_$+$$_$+$$$_+$$_$
$$$ +$$+$$ _+_$+$$_$+$$$_+$$_$
 
Stay with React.js in 2020
Stay with React.js in 2020Stay with React.js in 2020
Stay with React.js in 2020
 
Transformations - how Oracle rewrites your statements
Transformations - how Oracle rewrites your statementsTransformations - how Oracle rewrites your statements
Transformations - how Oracle rewrites your statements
 
Indexing thousands of writes per second with redis
Indexing thousands of writes per second with redisIndexing thousands of writes per second with redis
Indexing thousands of writes per second with redis
 
DRUPAL 8 STORAGES OVERVIEW
DRUPAL 8 STORAGES OVERVIEWDRUPAL 8 STORAGES OVERVIEW
DRUPAL 8 STORAGES OVERVIEW
 
Regexes and-performance-testing
Regexes and-performance-testingRegexes and-performance-testing
Regexes and-performance-testing
 
Data20161007
Data20161007Data20161007
Data20161007
 
Optimizando MySQL
Optimizando MySQLOptimizando MySQL
Optimizando MySQL
 
JDD 2013 JavaFX
JDD 2013 JavaFXJDD 2013 JavaFX
JDD 2013 JavaFX
 
R Language
R LanguageR Language
R Language
 
ZFConf 2010: Zend Framework & MVC, Model Implementation (Part 2, Dependency I...
ZFConf 2010: Zend Framework & MVC, Model Implementation (Part 2, Dependency I...ZFConf 2010: Zend Framework & MVC, Model Implementation (Part 2, Dependency I...
ZFConf 2010: Zend Framework & MVC, Model Implementation (Part 2, Dependency I...
 
CS 542 Overview of query processing
CS 542 Overview of query processingCS 542 Overview of query processing
CS 542 Overview of query processing
 
Frank Rodenbaugh Portfolio
Frank Rodenbaugh PortfolioFrank Rodenbaugh Portfolio
Frank Rodenbaugh Portfolio
 
Task 2
Task 2Task 2
Task 2
 
Vb file
Vb fileVb file
Vb file
 
Presentation1
Presentation1Presentation1
Presentation1
 
Hacking Your Way To Better Security - Dutch PHP Conference 2016
Hacking Your Way To Better Security - Dutch PHP Conference 2016Hacking Your Way To Better Security - Dutch PHP Conference 2016
Hacking Your Way To Better Security - Dutch PHP Conference 2016
 
Xhtml tags reference
Xhtml tags referenceXhtml tags reference
Xhtml tags reference
 
Type safe embedded domain-specific languages
Type safe embedded domain-specific languagesType safe embedded domain-specific languages
Type safe embedded domain-specific languages
 
Rspec and Rails
Rspec and RailsRspec and Rails
Rspec and Rails
 

En vedette

How To Use Open Office. Impress
How To Use Open Office. ImpressHow To Use Open Office. Impress
How To Use Open Office. ImpressArulalan T
 
Automatic B Day Remainder Program
Automatic B Day Remainder ProgramAutomatic B Day Remainder Program
Automatic B Day Remainder ProgramArulalan T
 
presmarked
presmarkedpresmarked
presmarkedeswa
 
Python an-intro - odp
Python an-intro - odpPython an-intro - odp
Python an-intro - odpArulalan T
 
"contour.py" module
"contour.py" module"contour.py" module
"contour.py" moduleArulalan T
 
contour analysis and visulaization documetation -1
contour analysis and visulaization documetation -1contour analysis and visulaization documetation -1
contour analysis and visulaization documetation -1Arulalan T
 

En vedette (7)

How To Use Open Office. Impress
How To Use Open Office. ImpressHow To Use Open Office. Impress
How To Use Open Office. Impress
 
Automatic B Day Remainder Program
Automatic B Day Remainder ProgramAutomatic B Day Remainder Program
Automatic B Day Remainder Program
 
presmarked
presmarkedpresmarked
presmarked
 
Cv Gaby
Cv GabyCv Gaby
Cv Gaby
 
Python an-intro - odp
Python an-intro - odpPython an-intro - odp
Python an-intro - odp
 
"contour.py" module
"contour.py" module"contour.py" module
"contour.py" module
 
contour analysis and visulaization documetation -1
contour analysis and visulaization documetation -1contour analysis and visulaization documetation -1
contour analysis and visulaization documetation -1
 

Similaire à comboboxentry - glade - ruby - guide

Gift-VT Tools Development Overview
Gift-VT Tools Development OverviewGift-VT Tools Development Overview
Gift-VT Tools Development Overviewstn_tkiller
 
hello- please dont just copy from other answers- the following is the.docx
hello- please dont just copy from other answers- the following is the.docxhello- please dont just copy from other answers- the following is the.docx
hello- please dont just copy from other answers- the following is the.docxIsaac9LjWelchq
 
Csphtp1 18
Csphtp1 18Csphtp1 18
Csphtp1 18HUST
 
Please solve the following problem using C++- Thank you Instructions-.docx
Please solve the following problem using C++- Thank you Instructions-.docxPlease solve the following problem using C++- Thank you Instructions-.docx
Please solve the following problem using C++- Thank you Instructions-.docxPeterlqELawrenceb
 
In this lab, we will write an application to store a deck of cards i.pdf
In this lab, we will write an application to store a deck of cards i.pdfIn this lab, we will write an application to store a deck of cards i.pdf
In this lab, we will write an application to store a deck of cards i.pdfcontact41
 
Please the following is the currency class of perious one- class Curre.pdf
Please the following is the currency class of perious one- class Curre.pdfPlease the following is the currency class of perious one- class Curre.pdf
Please the following is the currency class of perious one- class Curre.pdfadmin463580
 
DBIx-DataModel v2.0 in detail
DBIx-DataModel v2.0 in detail DBIx-DataModel v2.0 in detail
DBIx-DataModel v2.0 in detail Laurent Dami
 
Ruby on Rails Intro
Ruby on Rails IntroRuby on Rails Intro
Ruby on Rails Introzhang tao
 
please code in c#- please note that im a complete beginner- northwind.docx
please code in c#- please note that im a complete beginner-  northwind.docxplease code in c#- please note that im a complete beginner-  northwind.docx
please code in c#- please note that im a complete beginner- northwind.docxAustinaGRPaigey
 
Extending MySQL Enterprise Monitor
Extending MySQL Enterprise MonitorExtending MySQL Enterprise Monitor
Extending MySQL Enterprise MonitorMark Leith
 
Using REST and XML Builder for legacy XML
Using REST and XML Builder for legacy XMLUsing REST and XML Builder for legacy XML
Using REST and XML Builder for legacy XMLKeith Pitty
 
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 3 of 5 b...
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 3 of 5  b...Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 3 of 5  b...
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 3 of 5 b...ssuserd6b1fd
 
Zend framework 05 - ajax, json and j query
Zend framework 05 - ajax, json and j queryZend framework 05 - ajax, json and j query
Zend framework 05 - ajax, json and j queryTricode (part of Dept)
 
What you forgot from your Computer Science Degree
What you forgot from your Computer Science DegreeWhat you forgot from your Computer Science Degree
What you forgot from your Computer Science DegreeStephen Darlington
 
Lecture 3 Perl & FreeBSD administration
Lecture 3 Perl & FreeBSD administrationLecture 3 Perl & FreeBSD administration
Lecture 3 Perl & FreeBSD administrationMohammed Farrag
 

Similaire à comboboxentry - glade - ruby - guide (20)

Gift-VT Tools Development Overview
Gift-VT Tools Development OverviewGift-VT Tools Development Overview
Gift-VT Tools Development Overview
 
hello- please dont just copy from other answers- the following is the.docx
hello- please dont just copy from other answers- the following is the.docxhello- please dont just copy from other answers- the following is the.docx
hello- please dont just copy from other answers- the following is the.docx
 
Csphtp1 18
Csphtp1 18Csphtp1 18
Csphtp1 18
 
J Query Public
J Query PublicJ Query Public
J Query Public
 
Please solve the following problem using C++- Thank you Instructions-.docx
Please solve the following problem using C++- Thank you Instructions-.docxPlease solve the following problem using C++- Thank you Instructions-.docx
Please solve the following problem using C++- Thank you Instructions-.docx
 
In this lab, we will write an application to store a deck of cards i.pdf
In this lab, we will write an application to store a deck of cards i.pdfIn this lab, we will write an application to store a deck of cards i.pdf
In this lab, we will write an application to store a deck of cards i.pdf
 
Please the following is the currency class of perious one- class Curre.pdf
Please the following is the currency class of perious one- class Curre.pdfPlease the following is the currency class of perious one- class Curre.pdf
Please the following is the currency class of perious one- class Curre.pdf
 
DBIx-DataModel v2.0 in detail
DBIx-DataModel v2.0 in detail DBIx-DataModel v2.0 in detail
DBIx-DataModel v2.0 in detail
 
Ruby gems
Ruby gemsRuby gems
Ruby gems
 
Ruby on Rails Intro
Ruby on Rails IntroRuby on Rails Intro
Ruby on Rails Intro
 
please code in c#- please note that im a complete beginner- northwind.docx
please code in c#- please note that im a complete beginner-  northwind.docxplease code in c#- please note that im a complete beginner-  northwind.docx
please code in c#- please note that im a complete beginner- northwind.docx
 
Extending MySQL Enterprise Monitor
Extending MySQL Enterprise MonitorExtending MySQL Enterprise Monitor
Extending MySQL Enterprise Monitor
 
Perl
PerlPerl
Perl
 
Using REST and XML Builder for legacy XML
Using REST and XML Builder for legacy XMLUsing REST and XML Builder for legacy XML
Using REST and XML Builder for legacy XML
 
SQL -PHP Tutorial
SQL -PHP TutorialSQL -PHP Tutorial
SQL -PHP Tutorial
 
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 3 of 5 b...
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 3 of 5  b...Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 3 of 5  b...
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 3 of 5 b...
 
Zend framework 05 - ajax, json and j query
Zend framework 05 - ajax, json and j queryZend framework 05 - ajax, json and j query
Zend framework 05 - ajax, json and j query
 
What you forgot from your Computer Science Degree
What you forgot from your Computer Science DegreeWhat you forgot from your Computer Science Degree
What you forgot from your Computer Science Degree
 
Tres Gemas De Ruby
Tres Gemas De RubyTres Gemas De Ruby
Tres Gemas De Ruby
 
Lecture 3 Perl & FreeBSD administration
Lecture 3 Perl & FreeBSD administrationLecture 3 Perl & FreeBSD administration
Lecture 3 Perl & FreeBSD administration
 

Plus de Arulalan T

Climate Data Operators (CDO)
Climate Data Operators (CDO)Climate Data Operators (CDO)
Climate Data Operators (CDO)Arulalan T
 
CDAT - graphics - vcs - xmgrace - Introduction
CDAT - graphics - vcs - xmgrace - Introduction CDAT - graphics - vcs - xmgrace - Introduction
CDAT - graphics - vcs - xmgrace - Introduction Arulalan T
 
CDAT - cdms2, maskes, cdscan, cdutil, genutil - Introduction
CDAT - cdms2, maskes, cdscan, cdutil, genutil - Introduction CDAT - cdms2, maskes, cdscan, cdutil, genutil - Introduction
CDAT - cdms2, maskes, cdscan, cdutil, genutil - Introduction Arulalan T
 
CDAT - cdms numpy arrays - Introduction
CDAT - cdms numpy arrays - IntroductionCDAT - cdms numpy arrays - Introduction
CDAT - cdms numpy arrays - IntroductionArulalan T
 
Python an-intro-python-month-2013
Python an-intro-python-month-2013Python an-intro-python-month-2013
Python an-intro-python-month-2013Arulalan T
 
Python an-intro v2
Python an-intro v2Python an-intro v2
Python an-intro v2Arulalan T
 
Thermohaline Circulation & Climate Change
Thermohaline Circulation & Climate ChangeThermohaline Circulation & Climate Change
Thermohaline Circulation & Climate ChangeArulalan T
 
Testing in-python-and-pytest-framework
Testing in-python-and-pytest-frameworkTesting in-python-and-pytest-framework
Testing in-python-and-pytest-frameworkArulalan T
 
Pygrib documentation
Pygrib documentationPygrib documentation
Pygrib documentationArulalan T
 
Lesson1 python an introduction
Lesson1 python an introductionLesson1 python an introduction
Lesson1 python an introductionArulalan T
 
Python An Intro
Python An IntroPython An Intro
Python An IntroArulalan T
 
Final review contour
Final review  contourFinal review  contour
Final review contourArulalan T
 
Contour Ilugc Demo Presentation
Contour Ilugc Demo Presentation Contour Ilugc Demo Presentation
Contour Ilugc Demo Presentation Arulalan T
 
Contour Ilugc Demo Presentation
Contour Ilugc Demo PresentationContour Ilugc Demo Presentation
Contour Ilugc Demo PresentationArulalan T
 
Edit/correct India Map In Cdat Documentation - With Edited World Map Data
Edit/correct India Map In Cdat  Documentation -  With Edited World Map Data Edit/correct India Map In Cdat  Documentation -  With Edited World Map Data
Edit/correct India Map In Cdat Documentation - With Edited World Map Data Arulalan T
 
matplotlib-installatin-interactive-contour-example-guide
matplotlib-installatin-interactive-contour-example-guidematplotlib-installatin-interactive-contour-example-guide
matplotlib-installatin-interactive-contour-example-guideArulalan T
 
Sms frame work using gnokii, ruby & csv - command line argument
Sms frame work using gnokii, ruby & csv - command line argument Sms frame work using gnokii, ruby & csv - command line argument
Sms frame work using gnokii, ruby & csv - command line argument Arulalan T
 
sms frame work
sms frame worksms frame work
sms frame workArulalan T
 

Plus de Arulalan T (20)

wgrib2
wgrib2wgrib2
wgrib2
 
Climate Data Operators (CDO)
Climate Data Operators (CDO)Climate Data Operators (CDO)
Climate Data Operators (CDO)
 
CDAT - graphics - vcs - xmgrace - Introduction
CDAT - graphics - vcs - xmgrace - Introduction CDAT - graphics - vcs - xmgrace - Introduction
CDAT - graphics - vcs - xmgrace - Introduction
 
CDAT - cdms2, maskes, cdscan, cdutil, genutil - Introduction
CDAT - cdms2, maskes, cdscan, cdutil, genutil - Introduction CDAT - cdms2, maskes, cdscan, cdutil, genutil - Introduction
CDAT - cdms2, maskes, cdscan, cdutil, genutil - Introduction
 
CDAT - cdms numpy arrays - Introduction
CDAT - cdms numpy arrays - IntroductionCDAT - cdms numpy arrays - Introduction
CDAT - cdms numpy arrays - Introduction
 
Python an-intro-python-month-2013
Python an-intro-python-month-2013Python an-intro-python-month-2013
Python an-intro-python-month-2013
 
Python an-intro v2
Python an-intro v2Python an-intro v2
Python an-intro v2
 
Thermohaline Circulation & Climate Change
Thermohaline Circulation & Climate ChangeThermohaline Circulation & Climate Change
Thermohaline Circulation & Climate Change
 
Testing in-python-and-pytest-framework
Testing in-python-and-pytest-frameworkTesting in-python-and-pytest-framework
Testing in-python-and-pytest-framework
 
Pygrib documentation
Pygrib documentationPygrib documentation
Pygrib documentation
 
Lesson1 python an introduction
Lesson1 python an introductionLesson1 python an introduction
Lesson1 python an introduction
 
Python An Intro
Python An IntroPython An Intro
Python An Intro
 
Final review contour
Final review  contourFinal review  contour
Final review contour
 
Contour Ilugc Demo Presentation
Contour Ilugc Demo Presentation Contour Ilugc Demo Presentation
Contour Ilugc Demo Presentation
 
Contour Ilugc Demo Presentation
Contour Ilugc Demo PresentationContour Ilugc Demo Presentation
Contour Ilugc Demo Presentation
 
Edit/correct India Map In Cdat Documentation - With Edited World Map Data
Edit/correct India Map In Cdat  Documentation -  With Edited World Map Data Edit/correct India Map In Cdat  Documentation -  With Edited World Map Data
Edit/correct India Map In Cdat Documentation - With Edited World Map Data
 
Nomography
NomographyNomography
Nomography
 
matplotlib-installatin-interactive-contour-example-guide
matplotlib-installatin-interactive-contour-example-guidematplotlib-installatin-interactive-contour-example-guide
matplotlib-installatin-interactive-contour-example-guide
 
Sms frame work using gnokii, ruby & csv - command line argument
Sms frame work using gnokii, ruby & csv - command line argument Sms frame work using gnokii, ruby & csv - command line argument
Sms frame work using gnokii, ruby & csv - command line argument
 
sms frame work
sms frame worksms frame work
sms frame work
 

Dernier

Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfSanaAli374401
 
Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.MateoGardella
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Shubhangi Sonawane
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfChris Hunter
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingTeacherCyreneCayanan
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 

Dernier (20)

Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdf
 
Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 

comboboxentry - glade - ruby - guide

  • 1. A Exercise on Interdependent select (or chained select) using ComboBoxEntry in Glade3 And Ruby Core: w are going to develop chained selection module using comboboxentry . In first comboboxentry, will list out countries names, when user select any one of countries from this list, application will display another dependent comboboxentry. The second comboboxentry have to list out “states” which are all corresponding to selected country in first comboboxentry box. Then it will be displayed , third comboboxentry & it will list out cities corresponding to the selected state in second comboboxentry box. How to install ruby : $sudo apt-get install ruby How to install glade : $sudo apt-get install glade Or goto 'synaptic package mamager' and find glade3, select mark for installation and click 'Apply' button. ruby-glade-create-template command : To run this command we have to install ruby package, $sudo apt-get install libglade2-ruby How to install active-record : $sudo apt-get install rubygems $sudo gem install activerecord Error : While installing activerecord , it will show following error:
  • 2. usr/bin/gem:10: undefined method `manage_gems' for Gem:Module (NoMethodError) For that do the following: $sudo gedit /usr/bin/gem add the following two lines in top of the coding : require 'rubygems' require 'rubygems/gem_runner' and comment the next line by #Gem.manage_gems Glade Guide 1). Drag and drop “Window” from Top Level Window 2). Place “Fixed Layer” from Container in window 3). Take three “ComboBoxEntry” and place in window. 4). Set lable name to each comboboxentry and comboboxentry-entry1 to identify. Signal: set “changed “ signal to all comboboxentry widget. And save it as “combo.glade” Open Glade3 from Programming Application
  • 3. Opened Glade Window Select Window Widget and drop in design area
  • 4. Drag and drop “fixed” widget and plce inside toplevel window Take comboboxentry
  • 5. Change your comboboxentry widget label name to identify Allign and customize comboboxentry widget box size
  • 6. Set 'change siganl' to all comboboxentry from the “Signal”menu side panel
  • 7. Drag and drop the 'Label' widget & change label name & allign it. Final design view
  • 8. Ruby Guide $ ruby-glade-create-template combo.glade > combo.rb Initialize Method : Add one line inside initialize method as follow . @glade[“Window1”].show_all “Window1” is a default lable name of top level window. If u want change that lable name... Program : # Active Record require 'libglade2' require 'rubygems' require 'active_record' ActiveRecord::Base.logger = Logger.new(STDERR) ActiveRecord::Base.colorize_logging = false ActiveRecord::Base.establish_connection( :adapter => quot;mysqlquot;, :encoding => quot;utf8quot;, :database => quot;countryquot;, :username => quot;rootquot;, :password =>quot;passwordquot;, :socket => quot;/var/run/mysqld/mysqld.sockquot;, :dbfile => quot;:memory:quot; ) ActiveRecord::Schema.define do create_table :countries do |table| table.column :name, :string end
  • 9. create_table :states do |table| table.column :country_id, :integer table.column :name, :string end create_table :cities do |table| table.column :state_id, :integer table.column :name, :string end end =begin create database “ country” in your mysql by excuting this query “mysql > create database country; “. And set your mysql root user name “root” and “password” in the above code. You can understand easily by seeing the above code, how active record creates tables and corresponding fields. Create_table: 'table name' - - - > It will create table in db. Column: name, :String ( Field Type) - - -> It will set column field by this type and name. =end # Relationships : class Country < ActiveRecord::Base has_many :state end class State < ActiveRecord::Base belongs_to :country has_many :cities end class City < ActiveRecord::Base belongs_to :state end =begin This tells about relationships among those tables...
  • 10. “Country “ table record entries having relationship with so many “State” table record entries... simply we can represent by one to many relationship, so in this case we have used “ has_many ”. This means a country “has_many” states. “State” table record entries having relations under “Country” table record entries.... It can be represented by “ belongs_to “. Since every state belongs to a country hence we have used “belongs_to” in the state class to say that it belongs to a country. =end # Populating values into tables : country=Country.new(:name=>'India') country.save # here we are inserting value 'India' into country table country.state << State.new(:name => 'TamilNadu') # it will insert value 'TamilNadu' into state table with country_id country.state.find(:all,:conditions => {:name => 'TamilNadu'}).first.cities << City.new(:name =>'Chennai') # it will append the new entries ' Chennai ' in “city” table with 'Country_id' and ' State_id' . country=Country.new(:name=>'America') country.save country.state << State.new(:name => 'Ohio') country.state.find(:all,:conditions => {:name => 'Ohio'}).first.cities << City.new(:name =>'Chicago') # Like wise, you can insert values into three tables as your wish # and insert more country, states and city names in corresponding tables . . . class ComboCountryGlade include GetText attr :glade def initialize(path_or_data, root = nil, domain = nil, localedir = nil, flag = GladeXML::FILE) bindtextdomain(domain, localedir, nil, quot;UTF-8quot;) @glade = GladeXML.new(path_or_data, root, domain, localedir, flag) {|handler| method(handler)}
  • 11. @glade['window1'].show_all country_combo _method end # ComboBoxEntry Methods # country method : def country_combo_method @glade[quot;country_comboboxentryquot;].show_all @glade[quot;state_comboboxentryquot;].hide_all @glade[quot;State_labelquot;].hide_all @glade[quot;city_comboboxentryquot;].hide_all @glade[quot;City_labelquot;].hide_all # here, we are hiding state and city comboboxentry and their lables @country_combobox = @glade[quot;country_comboboxentryquot;] @country_list = Gtk::ListStore.new(String) @country_cell = Gtk::CellRendererText.new() # here, we are setting comboboxentry properties to box by calling inbuild Gtk methods @country_combobox.pack_start(@country_cell, true) @country_combobox.add_attribute(@country_cell, 'text',0) @country_combobox.set_model(@country_list) @country=Country.all # here, we calling active record class. # [Country.all] ---> it will return all countries entries @country.each do |country_name| @country_iter =@country_list.append @country_iter[0] =country_name.name end end =begin here, c_name is iterative variable of @country array record. From that, we need “ country name field alone”, so that we use [c_name.name] ----> it will return countries name. [@c_list_cat.append] -----> it will helps to append strings in comboboxentry. =end
  • 12. # ComboBoxEntry change signal code : for country def on_country_comboboxentry_changed(widget) @country_click_iter= @glade['country_comboboxentry'].active_iter @country_list.each do |model,path,@iter_country| if path.to_s == @country_click_iter.to_s @glade['country_comboboxentry-entry1'].text =@iter_country[0] country_name=@glade['country_comboboxentry-entry1'].text @state_combo = @glade[quot;state_comboboxentryquot;] @state_combo.clear state_combo_method(country_name) end end end =begin active_iter : return , pointer of comboboxentry list by corresponding to mouse or keyboard press on list. path.to_s : to identify TreeView path of combobox entry. state_combo(country_name) : Iside country change signal method, we are going to call “ State Comboboxentry and passing argument as country name, which is selected by user at run time. same like this logic we have to write code for state and city comboboxentries also . =end # State mathod : def state_combo_method(country_name) @glade[quot;state_comboboxentryquot;].show_all @glade[quot;State_labelquot;].show_all @glade[quot;city_comboboxentryquot;].hide_all @glade[quot;City_labelquot;].hide_all @state_combobox = @glade[quot;state_comboboxentryquot;] @state_list = Gtk::ListStore.new(String) @state_cell = Gtk::CellRendererText.new() @glade['state_comboboxentry-entry2'].text=quot;quot;
  • 13. @state_combobox.pack_start(@state_cell, true) @state_combobox.add_attribute(@state_cell, 'text',0) @state_combobox.set_model(@state_list) country1=Country.find(:all,:conditions=>{:name=>country_name}).first.state country1.each do |state_name| @state_iter =@state_list.append @state_iter[0] =state_name.name end end # ComboBoxEntry change signal code : for state def on_state_comboboxentry_changed(widget) state_click_iter= @glade['state_comboboxentry'].active_iter @state_list.each do |model,path,@iter_state| if path.to_s == state_click_iter.to_s @glade['state_comboboxentry-entry2'].text =@iter_state[0] state_name= @glade['state_comboboxentry-entry2'].text @city_combo=@glade[quot;city_comboboxentryquot;] @city_combo.clear city_combo_method( state_name) end end end end # city method : def city_combo_method(state_name) @glade[quot;city_comboboxentryquot;].show_all @glade[quot;City_labelquot;].show_all @city_combo = @glade[quot;city_comboboxentryquot;] @city_list = Gtk::ListStore.new(String) @city_cell = Gtk::CellRendererText.new() @glade['city_comboboxentry-entry3'].text=quot;quot; @city_combo.pack_start(@city_cell, true)
  • 14. @city_combo.add_attribute(@city_cell, 'text',0) @city_combo.set_model(@city_list) city=State.all(:conditions=>{:name=>state_name}).first.cities city.each do |city_name| @city_iter =@city_list.append @city_iter[0] =city_name.name end end # ComboBoxEntry change signal code : for city def on_city_comboboxentry_changed(widget) @city_click_iter= @glade['city_comboboxentry'].active_iter @city_list.each do |model,path,@iter_city| if path.to_s == @city_click_iter.to_s @glade['city_comboboxentry-entry3'].text =@iter_city[0] end end end # Main program for glade if __FILE__ == $0 # Set values as your own application. PROG_PATH = quot;combo_country.gladequot; PROG_NAME = quot;YOUR_APPLICATION_NAMEquot; ComboCountryGlade.new(PROG_PATH, nil, PROG_NAME) Gtk.main end # End of program =begin Save the whole program as combo.rb And then run this program in terminal. $ruby combo.rb while running this combo.rb , combo.glade file must contain in the same folder. =end
  • 15. Output window :1 Output window : 2 Output window : 3
  • 16. Output window : 4 Output window : 5 Output window : 6
  • 17. Output window : 7 Use : Using this Chained Selection program , we are developing a school management application with following scenerio . first select one 'class' from class_combobox_entry and then choose 'section' from section_combobox_entry and then finally select 'student name' from student_combobox_entry. You can download this source code from : http://gist.github.com/127848 http://comboboxentry-glade-ruby.blogspot.com/
  • 18. Enjoy with Ruby and Glade . Best wishes from Arulalan.T