Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
P
Python-Roadshow
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
workshops
Python-Roadshow
Commits
52d994cd
Commit
52d994cd
authored
Jan 20, 2018
by
SCtom
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
http://projectcs.sci.ubu.ac.th/workshops/Python-Roadshow
parents
66cc13b3
b443d09f
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
116 additions
and
0 deletions
+116
-0
ezcal.py
Session-3 Dr.K-v4/lecture/ezcal.py
+71
-0
first.py
Session-3 Dr.K-v4/lecture/first.py
+11
-0
second.py
Session-3 Dr.K-v4/lecture/second.py
+34
-0
พัฒนาโปรแกรมสำหรับคอมพิวเตอร์.pdf
Session-3 Dr.K-v4/lecture/พัฒนาโปรแกรมสำหรับคอมพิวเตอร์.pdf
+0
-0
No files found.
Session-3 Dr.K-v4/lecture/ezcal.py
0 → 100644
View file @
52d994cd
import
sys
from
PyQt5.QtWidgets
import
(
QApplication
,
QWidget
,
QGridLayout
,
QVBoxLayout
,
QHBoxLayout
,
QLabel
,
QLineEdit
,
QPushButton
)
class
MainWindow
(
QWidget
):
def
__init__
(
self
,
parent
=
None
):
super
(
MainWindow
,
self
)
.
__init__
(
parent
)
#สร้างปุ่มและช่องกรอกข้อมูล
self
.
firstNumber
=
QLineEdit
()
self
.
secondNumber
=
QLineEdit
()
self
.
outputLine
=
QLineEdit
()
self
.
outputLine
.
setReadOnly
(
True
)
self
.
sumButton
=
QPushButton
(
"บวก"
)
self
.
sumButton
.
clicked
.
connect
(
self
.
sum
)
#กำหนดการทำงานให้ปุ่มบวก
self
.
subButton
=
QPushButton
(
"ลบ"
)
self
.
subButton
.
clicked
.
connect
(
self
.
sub
)
#กำหนดการทำงานให้ปุ่มลบ
self
.
mulButton
=
QPushButton
(
"คูณ"
)
self
.
mulButton
.
clicked
.
connect
(
self
.
mul
)
#กำหนดการทำงานให้ปุ่มคูณ
self
.
divButton
=
QPushButton
(
"หาร"
)
self
.
divButton
.
clicked
.
connect
(
self
.
div
)
#กำหนดการทำงานให้ปุ่มหาร
self
.
expButton
=
QPushButton
(
"ยกกำลัง"
)
self
.
expButton
.
clicked
.
connect
(
self
.
exp
)
#กำหนดการทำงานให้ปุ่มยกกำลัง
#จัดวางปุ่นต่าง ๆ ลงหน้าจอ
lineLayout
=
QGridLayout
()
lineLayout
.
addWidget
(
QLabel
(
"ตัวแรก"
),
0
,
0
)
lineLayout
.
addWidget
(
self
.
firstNumber
,
0
,
1
)
lineLayout
.
addWidget
(
QLabel
(
"ตัวที่สอง"
),
1
,
0
)
lineLayout
.
addWidget
(
self
.
secondNumber
,
1
,
1
)
lineLayout
.
addWidget
(
QLabel
(
"ผลลัพธ์"
),
2
,
0
)
lineLayout
.
addWidget
(
self
.
outputLine
,
2
,
1
)
buttonLayout
=
QVBoxLayout
()
buttonLayout
.
addWidget
(
self
.
sumButton
)
buttonLayout
.
addWidget
(
self
.
subButton
)
buttonLayout
.
addWidget
(
self
.
mulButton
)
buttonLayout
.
addWidget
(
self
.
divButton
)
buttonLayout
.
addWidget
(
self
.
expButton
)
mainLayout
=
QHBoxLayout
()
mainLayout
.
addLayout
(
lineLayout
)
mainLayout
.
addLayout
(
buttonLayout
)
self
.
setLayout
(
mainLayout
)
self
.
setWindowTitle
(
"EZ calculator"
)
#นิยามการบวกเลขสองตัว
def
sum
(
self
):
n
=
int
(
self
.
firstNumber
.
text
())
#รับค่ามาจากช่อง"ตัวแรก"
r
=
int
(
self
.
secondNumber
.
text
())
#รับค่ามาจากช่อง"ตัวที่สอง"
self
.
outputLine
.
setText
(
str
(
n
+
r
))
#กำหนดค่าให้ช่อง"ผลลัพธ์"
#นิยามการลบเลขสองตัว
def
sub
(
self
):
n
=
0
r
=
0
self
.
outputLine
.
setText
()
#นิยามการคูณเลขสองตัว
def
mul
(
self
):
n
=
0
r
=
0
self
.
outputLine
.
setText
()
#นิยามการหารเลขสองตัว
def
div
(
self
):
n
=
0
r
=
0
self
.
outputLine
.
setText
()
#นิยามการยกกำลังเลขสองตัว
def
exp
(
self
):
n
=
0
r
=
0
self
.
outputLine
.
setText
()
if
__name__
==
'__main__'
:
app
=
QApplication
(
sys
.
argv
)
main_window
=
MainWindow
()
main_window
.
show
()
sys
.
exit
(
app
.
exec_
())
Session-3 Dr.K-v4/lecture/first.py
0 → 100644
View file @
52d994cd
import
sys
from
PyQt5.QtWidgets
import
QApplication
,
QWidget
if
__name__
==
'__main__'
:
app
=
QApplication
(
sys
.
argv
)
w
=
QWidget
()
w
.
resize
(
250
,
150
)
w
.
move
(
300
,
300
)
w
.
setWindowTitle
(
'Simple'
)
w
.
show
()
sys
.
exit
(
app
.
exec_
())
Session-3 Dr.K-v4/lecture/second.py
0 → 100644
View file @
52d994cd
import
sys
from
PyQt5.QtWidgets
import
QWidget
,
QLabel
,
QApplication
class
Example
(
QWidget
):
def
__init__
(
self
):
super
()
.
__init__
()
self
.
initUI
()
def
initUI
(
self
):
lbl1
=
QLabel
(
'Zetcode'
,
self
)
lbl1
.
move
(
15
,
10
)
lbl2
=
QLabel
(
'tutorials'
,
self
)
lbl2
.
move
(
35
,
40
)
lbl3
=
QLabel
(
'for programmers'
,
self
)
lbl3
.
move
(
55
,
70
)
self
.
setGeometry
(
300
,
300
,
250
,
150
)
self
.
setWindowTitle
(
'Absolute'
)
self
.
show
()
if
__name__
==
'__main__'
:
app
=
QApplication
(
sys
.
argv
)
ex
=
Example
()
sys
.
exit
(
app
.
exec_
())
\ No newline at end of file
Session-3 Dr.K-v4/lecture/พัฒนาโปรแกรมสำหรับคอมพิวเตอร์.pdf
0 → 100644
View file @
52d994cd
File added
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment