-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackFrontEnd.py
More file actions
47 lines (36 loc) · 923 Bytes
/
backFrontEnd.py
File metadata and controls
47 lines (36 loc) · 923 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/python3
'''
Created on 9 mar. 2017
@author: martintc
'''
'''
Detectar si fue ejecutado desde ventana o terminal
import os
import sys
isGUI = sys.stdin.isatty()
isNotGUI = os.isatty(sys.stdout.fileno())
if os.isatty(sys.stdout.fileno()):
# print error message text
else:
# display GUI message
You should check that the DISPLAY environment variable is set
before going with GUI code too, since it won't work without that.
'''
import sys
import os
WINDOWED = 'DISPLAY' in os.environ and not sys.stdin.isatty()
user = 'you'
if not WINDOWED:
user = sys.argv[1]
msg = "Hello, "+user+"!"
if WINDOWED:
import tkinter as tk
from tkinter import messagebox
root = tk.Tk()
root.withdraw()
messagebox.showinfo("stdin", "stdin is " + str(sys.stdin.isatty()))
messagebox.showinfo("Say Hello", msg)
else:
print("stdin is " + str(sys.stdin.isatty()))
print(msg)
input()