Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
Lab Advanced Software Development
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Bui2.Huan@live.uwe.ac.uk
Lab Advanced Software Development
Commits
1ff815fd
Commit
1ff815fd
authored
1 month ago
by
Bui2.Huan@live.uwe.ac.uk
Browse files
Options
Downloads
Patches
Plain Diff
Upload New File
parent
c9ffe7e3
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Week 10/activity6.py
+113
-0
113 additions, 0 deletions
Week 10/activity6.py
with
113 additions
and
0 deletions
Week 10/activity6.py
0 → 100644
+
113
−
0
View file @
1ff815fd
import
tkinter
as
tk
from
tkinter
import
ttk
,
messagebox
class
TabbedLoginApp
:
def
__init__
(
self
,
root
):
self
.
root
=
root
self
.
root
.
title
(
"
Tabbed Login Application
"
)
# Create the notebook (tabs container)
self
.
notebook
=
ttk
.
Notebook
(
self
.
root
)
self
.
notebook
.
pack
(
fill
=
'
both
'
,
expand
=
True
)
# Create Login tab
self
.
login_frame
=
ttk
.
Frame
(
self
.
notebook
)
self
.
notebook
.
add
(
self
.
login_frame
,
text
=
"
Login
"
)
self
.
create_login_tab
(
self
.
login_frame
)
# Create Data tab (for tabulated data)
self
.
data_frame
=
ttk
.
Frame
(
self
.
notebook
)
self
.
notebook
.
add
(
self
.
data_frame
,
text
=
"
Data
"
)
self
.
create_data_tab
(
self
.
data_frame
)
def
create_login_tab
(
self
,
frame
):
# Username label and entry
ttk
.
Label
(
frame
,
text
=
"
Username:
"
).
grid
(
row
=
0
,
column
=
0
,
padx
=
10
,
pady
=
10
,
sticky
=
'
e
'
)
self
.
entry_username
=
ttk
.
Entry
(
frame
)
self
.
entry_username
.
grid
(
row
=
0
,
column
=
1
,
padx
=
10
,
pady
=
10
)
# Password label and entry
ttk
.
Label
(
frame
,
text
=
"
Password:
"
).
grid
(
row
=
1
,
column
=
0
,
padx
=
10
,
pady
=
10
,
sticky
=
'
e
'
)
self
.
entry_password
=
ttk
.
Entry
(
frame
,
show
=
"
*
"
)
self
.
entry_password
.
grid
(
row
=
1
,
column
=
1
,
padx
=
10
,
pady
=
10
)
# Login button
login_button
=
ttk
.
Button
(
frame
,
text
=
"
Login
"
,
command
=
self
.
login
)
login_button
.
grid
(
row
=
2
,
column
=
0
,
columnspan
=
2
,
pady
=
10
)
# Register button (opens registration window)
register_button
=
ttk
.
Button
(
frame
,
text
=
"
Register
"
,
command
=
self
.
open_register
)
register_button
.
grid
(
row
=
3
,
column
=
0
,
columnspan
=
2
,
pady
=
5
)
def
login
(
self
):
# Simple login validation (replace with actual credential checking as needed)
username
=
self
.
entry_username
.
get
()
password
=
self
.
entry_password
.
get
()
if
username
==
"
admin
"
and
password
==
"
password
"
:
messagebox
.
showinfo
(
"
Login
"
,
"
Login successful!
"
)
else
:
messagebox
.
showwarning
(
"
Login
"
,
"
Invalid credentials!
\n
Please try again or register.
"
)
def
open_register
(
self
):
# Registration window for capturing new user details
reg_window
=
tk
.
Toplevel
(
self
.
root
)
reg_window
.
title
(
"
Register
"
)
ttk
.
Label
(
reg_window
,
text
=
"
Username:
"
).
grid
(
row
=
0
,
column
=
0
,
padx
=
10
,
pady
=
5
,
sticky
=
'
e
'
)
reg_username
=
ttk
.
Entry
(
reg_window
)
reg_username
.
grid
(
row
=
0
,
column
=
1
,
padx
=
10
,
pady
=
5
)
ttk
.
Label
(
reg_window
,
text
=
"
Password:
"
).
grid
(
row
=
1
,
column
=
0
,
padx
=
10
,
pady
=
5
,
sticky
=
'
e
'
)
reg_password
=
ttk
.
Entry
(
reg_window
,
show
=
"
*
"
)
reg_password
.
grid
(
row
=
1
,
column
=
1
,
padx
=
10
,
pady
=
5
)
ttk
.
Label
(
reg_window
,
text
=
"
Full Name:
"
).
grid
(
row
=
2
,
column
=
0
,
padx
=
10
,
pady
=
5
,
sticky
=
'
e
'
)
reg_fullname
=
ttk
.
Entry
(
reg_window
)
reg_fullname
.
grid
(
row
=
2
,
column
=
1
,
padx
=
10
,
pady
=
5
)
ttk
.
Label
(
reg_window
,
text
=
"
Email:
"
).
grid
(
row
=
3
,
column
=
0
,
padx
=
10
,
pady
=
5
,
sticky
=
'
e
'
)
reg_email
=
ttk
.
Entry
(
reg_window
)
reg_email
.
grid
(
row
=
3
,
column
=
1
,
padx
=
10
,
pady
=
5
)
def
submit_registration
():
# For demo purposes, just validate and show a message.
username
=
reg_username
.
get
()
password
=
reg_password
.
get
()
fullname
=
reg_fullname
.
get
()
email
=
reg_email
.
get
()
if
username
and
password
and
fullname
and
email
:
messagebox
.
showinfo
(
"
Registration
"
,
"
Registration successful!
"
)
reg_window
.
destroy
()
else
:
messagebox
.
showwarning
(
"
Registration
"
,
"
All fields are required!
"
)
submit_button
=
ttk
.
Button
(
reg_window
,
text
=
"
Submit
"
,
command
=
submit_registration
)
submit_button
.
grid
(
row
=
4
,
column
=
0
,
padx
=
10
,
pady
=
10
)
cancel_button
=
ttk
.
Button
(
reg_window
,
text
=
"
Cancel
"
,
command
=
reg_window
.
destroy
)
cancel_button
.
grid
(
row
=
4
,
column
=
1
,
padx
=
10
,
pady
=
10
)
def
create_data_tab
(
self
,
frame
):
# Create a Treeview widget for displaying tabulated data
columns
=
(
"
ID
"
,
"
Name
"
,
"
Role
"
)
self
.
tree
=
ttk
.
Treeview
(
frame
,
columns
=
columns
,
show
=
'
headings
'
)
for
col
in
columns
:
self
.
tree
.
heading
(
col
,
text
=
col
)
self
.
tree
.
column
(
col
,
width
=
100
)
self
.
tree
.
pack
(
fill
=
'
both
'
,
expand
=
True
,
padx
=
10
,
pady
=
10
)
# Insert sample data into the table
sample_data
=
[
(
1
,
"
Alice
"
,
"
Developer
"
),
(
2
,
"
Bob
"
,
"
Designer
"
),
(
3
,
"
Charlie
"
,
"
Manager
"
)
]
for
item
in
sample_data
:
self
.
tree
.
insert
(
""
,
tk
.
END
,
values
=
item
)
def
main
():
root
=
tk
.
Tk
()
app
=
TabbedLoginApp
(
root
)
root
.
mainloop
()
if
__name__
==
"
__main__
"
:
main
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment