Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
310c657d
Commit
310c657d
authored
Nov 14, 1995
by
Jack Jansen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Control InterSLIP using a modal dialog
parent
07043b45
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
105 additions
and
0 deletions
+105
-0
Mac/Demo/example1/InterslipControl-1.py
Mac/Demo/example1/InterslipControl-1.py
+92
-0
Mac/Demo/example1/InterslipControl-1.rsrc.hqx
Mac/Demo/example1/InterslipControl-1.rsrc.hqx
+13
-0
No files found.
Mac/Demo/example1/InterslipControl-1.py
0 → 100644
View file @
310c657d
"""Sample program handling InterSLIP control and showing off EasyDialogs,
Res and Dlg in the process"""
import
EasyDialogs
import
Res
import
Dlg
import
sys
import
interslip
#
# Definitions for our resources
ID_MAIN
=
512
ITEM_CONNECT
=
1
ITEM_DISCONNECT
=
2
ITEM_UPDATE
=
3
ITEM_QUIT
=
4
ITEM_STATUS
=
5
ITEM_MESSAGE
=
6
status2text
=
[
"<idle>"
,
"<wait-modem>"
,
"<dialling>"
,
"<logging in>"
,
"<connected>"
,
"<disconnecting>"
]
def
main
():
"""Main routine: open resourcefile, open interslip, call dialog handler"""
try
:
Res
.
OpenResFile
(
"InterslipControl-1.rsrc"
)
except
Res
.
Error
,
arg
:
EasyDialogs
.
Message
(
"Cannot open resource file InterslipControl-1.rsrc: "
+
arg
[
1
])
sys
.
exit
(
1
)
try
:
interslip
.
open
()
except
interslip
.
error
,
arg
:
EasyDialogs
.
Message
(
"Cannot open interslip: "
+
arg
[
1
])
sys
.
exit
(
1
)
do_dialog
()
def
do_dialog
():
"""Post dialog and handle user interaction until quit"""
my_dlg
=
Dlg
.
GetNewDialog
(
ID_MAIN
,
-
1
)
while
1
:
n
=
Dlg
.
ModalDialog
(
None
)
if
n
==
ITEM_CONNECT
:
do_connect
()
elif
n
==
ITEM_DISCONNECT
:
do_disconnect
()
elif
n
==
ITEM_UPDATE
:
status
,
msg
=
do_status
()
# Convert status number to a text string
try
:
txt
=
status2text
[
status
]
except
IndexError
:
txt
=
"<unknown state %d>"
%
status
# Set the status text field
tp
,
h
,
rect
=
my_dlg
.
GetDialogItem
(
ITEM_STATUS
)
Dlg
.
SetDialogItemText
(
h
,
txt
)
# Set the message text field
tp
,
h
,
rect
=
my_dlg
.
GetDialogItem
(
ITEM_MESSAGE
)
Dlg
.
SetDialogItemText
(
h
,
msg
)
elif
n
==
ITEM_QUIT
:
break
def
do_connect
():
"""Connect, posting error message in case of failure"""
try
:
interslip
.
connect
()
except
interslip
.
error
,
arg
:
EasyDialogs
.
Message
(
"Cannot connect: "
+
arg
[
1
])
def
do_disconnect
():
"""Disconnect, posting error message in case of failure"""
try
:
interslip
.
disconnect
()
except
interslip
.
error
,
arg
:
EasyDialogs
.
Message
(
"Cannot disconnect: "
+
arg
[
1
])
def
do_status
():
"""Get status as (state_index, message),
posting error message in case of failure"""
try
:
status
,
msgnum
,
msg
=
interslip
.
status
()
except
interslip
.
error
,
arg
:
EasyDialogs
.
Message
(
"Cannot get status: "
+
arg
[
1
])
return
0
,
''
return
status
,
msg
main
()
Mac/Demo/example1/InterslipControl-1.rsrc.hqx
0 → 100644
View file @
310c657d
(This file must be converted with BinHex 4.0)
:&dPZG'9bFfaTF%0[ER4bEf`Y-5jbFh*M!(*cFQ058d9%!*!)!LIr03#3"!%!N!-
"``#3!m-!N!0NCQBd4$9%-%3a4$*%-a*QCM-c0%8e46"&-88b46-5CQBA5@jdCA*
cE'P`3fpZG(*[E#da,R*cFQ-#!*!$FR0bB`!!FR0bBe*6483"!!"R!(S!N"+X``N
h!*!'!LFcN!3d)!!e)!!`)!!a)!!b)!!c%M-c!!!d)!%e)!%`)!%a)!%b)!%c5b@
U5bQU5bUU5bZU5bbU5bfU5bkU5bp,0kT,1+T,1DT,1UT,1kT,2+T,2DT,2UT,2kT
,3+T,3DT,3UT,3kT,4+T,4DT,4UT,4kT,5+T,5DT,5UT,)!#U5b!!N!-9!'!!-J$
!!C)!!3%!!3#3"3)!N!@Q!!F!N!8m!!S!8!"@"!G$EfjZC@0d!*!'2!"D!&!!V`3
+4'PcBfpZEQ9MG!#3"6`!Y!"3!4F%$99`C'&dC5"cG'&dGA-!N!Bm!5)!8!&@"!4
4G@Pd!*!&#J"D!"S"9BJ!N!BH!&S!,J&@L!#3"JS!#J!D!&@)"e0dBA4eFcTK!*!
&(J!+!#i!9BJ)6@9cFf&RC6S!!!%!N!-"``#3!m-!N!0N!2!Xe"2@!*!$(!"'!!&
%6%p(!*!$%N4*9%`!N!-H!J#3#2!VV!)!!!m!N!-C!2!VE!j$EfjdFQpX)%4TB@a
[C`j$EfjdFQpX)'4TB@a[ChcP:
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