How can i use a tktable to show the data I've got from the Oracledatabase? - TCL

This is a discussion on How can i use a tktable to show the data I've got from the Oracledatabase? - TCL ; The data table just like this: MName E N Ro mat1 1 2 3 mat2 2 5 6...

+ Reply to Thread
Results 1 to 5 of 5

How can i use a tktable to show the data I've got from the Oracledatabase?

  1. Default How can i use a tktable to show the data I've got from the Oracledatabase?

    The data table just like this:


    MName E N Ro
    mat1 1 2 3
    mat2 2 5 6

  2. Default Re: How can i use a tktable to show the data I've got from the Oracledatabase?

    > The data table just like this:
    >
    >
    > MName E N Ro
    > mat1 1 2 3
    > mat2 2 5 6


    You've been posting a couple of different questions regarding Tktable.
    That is okay, but you have to be specific where your problem is.

    Candidates:
    - getting data from the database via Tcl
    - gui construction overall (toplevel / frame / ...)
    - Tcl syntax problems
    - or simply filling up the table with rows


    Regards,
    Eiji

  3. Default Re: How can i use a tktable to show the data I've got from the Oracledatabase?

    On 11月11日, 下午10时29分, eiji <eiji.anonrem...@googlemail.com> wrote:
    > > The data table just like this:

    >
    > > MName E N Ro
    > > mat1 1 2 3
    > > mat2 2 5 6

    >
    > You've been posting a couple of different questions regarding Tktable.
    > That is okay, but you have to be specific where your problem is.
    >
    > Candidates:
    > - getting data from the database via Tcl
    > - gui construction overall (toplevel / frame / ...)
    > - Tcl syntax problems
    > - or simply filling up the table with rows
    >
    > Regards,
    > Eiji


    The problem is how to use the data in the table fill the tktable??
    would you help me ?
    thanks!

  4. Default Re: How can i use a tktable to show the data I've got from the Oracledatabase?

    # some code to play with
    # (quick and dirty, not optimized for style, speed and functions)


    namespace eval ::dbtable {
    variable ns [namespace current]

    variable db
    array unset db

    array set db {
    MName {mat1 mat2}
    E {1 2}
    N {2 5}
    Ro {3 6}
    }
    }

    proc ::dbtable::BuildGui {} {

    variable ns

    catch {destroy .dbgui}
    set dbgui [toplevel .dbgui]

    set readButton [button $dbgui.readButton \
    -command ${ns}::ReadDataBase \
    -text "Fill from Database"]

    variable table [table $dbgui.table \
    -titlerows 1 \
    -variable ${ns}::tArray]

    set updateButton [button $dbgui.updateButton \
    -command ${ns}::UpdateDataBase \
    -text "Update Database from Table"]

    set clearButton [button $dbgui.clearButton \
    -command ${ns}::ClearTable \
    -text "Clear Table"]

    pack $readButton -fill x
    pack $table -fill both -expand true
    pack $updateButton -fill x
    pack $clearButton -fill x

    InitTable
    }

    proc ::dbtable::InitTable {} {
    variable table
    variable db

    $table config \
    -cols [llength [array names db]]

    ClearTable

    set col 0
    foreach title_col [lsort [array names db]] {
    $table set 0,$col $title_col
    incr col
    }

    $table tag config title \
    -fg black \
    -bg white \
    -relief raised \
    -showtext 1

    }

    proc ::dbtable::ClearTable {} {
    variable table
    $table delete rows -keeptitles -- 1 [$table cget -rows]
    }

    proc ::dbtable::ReadDataBase {} {
    #read your data and fill the table

    variable table
    variable db

    ClearTable

    $table insert rows end [llength $db([lindex [lsort [array names
    db]] 0])]

    set col 0
    foreach sets [lsort [array names db]] {

    $table set 0,$col $sets

    set row 1
    foreach data_cell $db($sets) {
    $table set $row,$col $data_cell
    incr row
    }
    incr col
    }

    }

    proc ::dbtable::UpdateDataBase {} {
    variable table
    variable db

    array unset db

    set keysNumber [$table cget -cols]
    for {set i 0} {$i < $keysNumber} {incr i} {
    set db([$table get 0,$i])[list]
    }
    #puts [$table get 1,0 end]
    set i 0
    foreach cell [$table get 1,0 end] {
    #puts "[$table get 0,[expr {$i % 4}]] : $db([$table get 0,
    [expr {$i % 4}]]) + $cell"
    lappend db([$table get 0,[expr {$i % 4}]]) $cell
    incr i
    }
    }

    ::dbtable::BuildGui

  5. Default Re: How can i use a tktable to show the data I've got from the Oracledatabase?

    On 11月11日, 下午11时51分, eiji <eiji.anonrem...@googlemail.com> wrote:
    > # some code to play with
    > # (quick and dirty, not optimized for style, speed and functions)
    >
    > namespace eval ::dbtable {
    > variable ns [namespace current]
    >
    > variable db
    > array unset db
    >
    > array set db {
    > MName {mat1 mat2}
    > E {1 2}
    > N {2 5}
    > Ro {3 6}
    > }
    >
    > }
    >
    > proc ::dbtable::BuildGui {} {
    >
    > variable ns
    >
    > catch {destroy .dbgui}
    > set dbgui [toplevel .dbgui]
    >
    > set readButton [button $dbgui.readButton \
    > -command ${ns}::ReadDataBase \
    > -text "Fill from Database"]
    >
    > variable table [table $dbgui.table \
    > -titlerows 1 \
    > -variable ${ns}::tArray]
    >
    > set updateButton [button $dbgui.updateButton \
    > -command ${ns}::UpdateDataBase \
    > -text "Update Database from Table"]
    >
    > set clearButton [button $dbgui.clearButton \
    > -command ${ns}::ClearTable \
    > -text "Clear Table"]
    >
    > pack $readButton -fill x
    > pack $table -fill both -expand true
    > pack $updateButton -fill x
    > pack $clearButton -fill x
    >
    > InitTable
    >
    > }
    >
    > proc ::dbtable::InitTable {} {
    > variable table
    > variable db
    >
    > $table config \
    > -cols [llength [array names db]]
    >
    > ClearTable
    >
    > set col 0
    > foreach title_col [lsort [array names db]] {
    > $table set 0,$col $title_col
    > incr col
    > }
    >
    > $table tag config title \
    > -fg black \
    > -bg white \
    > -relief raised \
    > -showtext 1
    >
    > }
    >
    > proc ::dbtable::ClearTable {} {
    > variable table
    > $table delete rows -keeptitles -- 1 [$table cget -rows]
    >
    > }
    >
    > proc ::dbtable::ReadDataBase {} {
    > #read your data and fill the table
    >
    > variable table
    > variable db
    >
    > ClearTable
    >
    > $table insert rows end [llength $db([lindex [lsort [array names
    > db]] 0])]
    >
    > set col 0
    > foreach sets [lsort [array names db]] {
    >
    > $table set 0,$col $sets
    >
    > set row 1
    > foreach data_cell $db($sets) {
    > $table set $row,$col $data_cell
    > incr row
    > }
    > incr col
    > }
    >
    > }
    >
    > proc ::dbtable::UpdateDataBase {} {
    > variable table
    > variable db
    >
    > array unset db
    >
    > set keysNumber [$table cget -cols]
    > for {set i 0} {$i < $keysNumber} {incr i} {
    > set db([$table get 0,$i])[list]
    > }
    > #puts [$table get 1,0 end]
    > set i 0
    > foreach cell [$table get 1,0 end] {
    > #puts "[$table get 0,[expr {$i % 4}]] : $db([$table get 0,
    > [expr {$i % 4}]]) + $cell"
    > lappend db([$table get 0,[expr {$i % 4}]]) $cell
    > incr i
    > }
    >
    > }
    >
    > ::dbtable::BuildGui


    Thanks it is very helpful.
    It is so good for you to do so.
    I really appreciated it !

+ Reply to Thread