Hi,
I'm using TclOO with SQLite to develop a database for a small library.
I created a class hierarchy for users with different privileges (normal user, administrator and super administrator) with the following structure.
http://c2o.pro.br/download/Pimentel/users_and_interface_classes.png
I use the notebook widget to organize tabs for the different users.
#Create a notebook widget with the ttk::notebook command.
ttk::notebook .n
#Create a frame to hold the widgets that will be shown in a tab.
ttk::frame .n.f1
#Add the frame to the notebook, supplying some text to display in the tab.
.n add .n.f1 -text "Query Books"
For normal user only tabs to query books and loans:
And for adminUser and superAdmin I include more tabs:
oo::class create interface {
constructor {id_user} {
next $id_user
}
}
oo::class create userInterface {
superclass interface
constructor { id_user } {
next $id_user
}
method buildInterface { } {
my QueryBookInterface
my QueryLoanInterface
}
method QueryBookInterface { } {
#Create a notebook widget with the ttk::notebook command.
ttk::notebook .n
#Create a frame to hold the widgets that will be shown in a tab.
ttk::frame .n.f1
#Add the frame to the notebook, supplying some text to display in the tab.
.n add .n.f1 -text "Query Book"
...
}
method QueryLoanInterface { } {
#Create a frame to hold the widgets that will be shown in a tab.
ttk::frame .n.f2
#Add the frame to the notebook, supplying some text to display in the tab.
.n add .n.f2 -text "Query Loan"
...
}
}
And additional tabs to query users, insert books, loans and other users.
oo::class create adminUserInterface {
superclass userInterface
constructor { id_user } {
next $id_user
}
method buildInterface { } {
my QueryBookInterface
my QueryLoanInterface
my QueryUserInterface
my InsertBookInterface
my InsertLoanInterface
my InsertUserInterface
}
method QueryUserInterface { } {
#Create a frame to hold the widgets that will be shown in a tab.
ttk::frame .n.f3
#Add the frame to the notebook, supplying some text to display in the tab.
.n add .n.f3 -text "Query User"
...
}
method InsertBookInterface { } {
ttk::frame .n.f4
.n add .n.f4 -text "Insert Book"
...
}
method InsertLoanInterface { } {
ttk::frame .n.f5
.n add .n.f5 -text "Insert Loan"
...
}
method InsertUserInterface { } {
...
}
}
And for super admin user only additional tab to insert other admin users:
oo::class create superAdminInterface {
superclass adminUserInterface
constructor { id_user } {
next $id_user
}
method buildInterface { } {
puts "buildInterface of superAdminInterface"
my QueryBookInterface
my QueryLoanInterface
my QueryUserInterface
my InsertBookInterface
my InsertLoanInterface
my InsertUserInterface
my InsertAdminInterface
}
method InsertAdminInterface { } {
ttk::frame .n.f7
.n add .n.f7 -text "Insert Administrator"
...
}
}
The classes for users with different privileges (user, adminUser, superAdmin):
oo::class create user {
mixin userInterface
variable state
constructor { id_user } {
set state(id_user) $id_user
}
...
}
oo::class create adminUser {
superclass user
mixin adminUserInterface
constructor { id_user } {
next $id_user
}
...
}
oo::class create superAdmin {
superclass adminUser
mixin superAdminInterface
constructor { id_user } {
next $id_user
}
...
}
After create a object for each user I call the method buildInterface.
set obj_user [user new 1]
$obj_user buildInterface
set obj_adminUser [adminUser new 1]
$obj_adminUser buildInterface
set obj_superAdmin [superAdmin new 1]
$obj_superAdmin buildInterface
To test I included radiobuttons, labelframe, entry, and listbox only on the tab for querybook.
It worked fine for user and adminUser as you can see:
Interface for normal user:
www.c2o.pro.br/download/Pimentel/window_for_normal_user.png
And the interface for adminUser:
www.c2o.pro.br/download/Pimentel/window_for_admin_user.png
But elements in tab for querybook don't appear when I create the interface for superadmin.
As you can see the interface for superAdmin:
www.c2o.pro.br/download/Pimentel/window_for_super_admin.png
Is there any limit to the number of tabs that can be created in a tabnote?
I don't know why it don't work for superAdmin.
Please, any tip?
Thanks,
Markos