Skip to content

Commit 1bb7c6a

Browse files
committed
feat(ui): add menus
feat(dist): support download file closes #8, 5
1 parent e8937b7 commit 1bb7c6a

5 files changed

Lines changed: 30 additions & 61 deletions

File tree

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
storage/
2-
dist/
32
build/

README.md

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
- Python 3.4.4 32bit (https://www.python.org/downloads/release/python-344/)
1313
- pyQt5.5.1 32bit (https://sourceforge.net/projects/pyqt/files/PyQt5/PyQt-5.5.1/)
1414

15+
## Download
16+
- Win32 QWebview-pluse 1.0 설치 파일
17+
18+
1519
## 키움 Open API+를 제공하는 kiwoom 객체 제공
1620

1721
### window.kiwoom
@@ -28,18 +32,6 @@
2832
- 이벤트에 의해 전달되는 속성은 detail에 포함되어 전달됨
2933
- 이벤트에 전달되는 속성명은 타입약어가 제거되고, 첫 문자를 소문자로 변경 `sScrNo => scrNo`
3034

31-
## 사용 예
32-
```bash
33-
python main.py -u [실행항 URL]
34-
python main.py -f [실행할 html 파일명]
35-
```
36-
> 실행할 파일을 입력하지 않을 경우, 기본적으로 index.html을 부른다.
37-
>
38-
> - -f --file 시작 페이지 경로 (기본: ./index.html)
39-
> - -u --url 시작 URL 경로
40-
>
41-
> **URL과 페이지 경로를 함께 입력했을 경우, URL이 우선한다.**
42-
4335
## [Kiwoom-Helper](https://github.com/sculove/Kiwoom-Helper) 유틸
4436
QWebview-Plus에서 제공하는 kiwoom 객체와 이벤트를 손쉽게 사용할 수 있는 유틸
4537
> 별도의 프로젝트로 관리 https://github.com/sculove/Kiwoom-Helper

dist/QWebview-plus-1.0-win32.msi

78.7 MB
Binary file not shown.
Lines changed: 25 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env pythonw
22
#-*-coding: utf-8 -*-
33
import sys
44
import os.path
55
import re
66
from optparse import OptionParser
77
from PyQt5.QtCore import QUrl
8-
from PyQt5.QtWidgets import QApplication, QFileDialog, qApp, QAction, QMainWindow, QStatusBar, QVBoxLayout, QSplitter, QMessageBox
8+
from PyQt5.QtWidgets import QApplication, QFileDialog, qApp, QAction, QMainWindow, QStatusBar, QVBoxLayout, QSplitter, QMessageBox, QInputDialog, QLineEdit
99
from plus.kiwoom import KiwoomWebViewPlus
1010

1111
class Window(QMainWindow):
@@ -14,16 +14,7 @@ def __init__(self):
1414
self.view = KiwoomWebViewPlus()
1515
self.initUI()
1616

17-
def initUI(self):
18-
self.setMinimumSize(1024, 640)
19-
self.setWindowTitle("QWebview-plus for Kiwoom")
20-
self.setCentralWidget(self.view)
21-
22-
self.view.statusbar = QStatusBar()
23-
self.setStatusBar(self.view.statusbar)
24-
self.view.statusbar.showMessage("[F4키] 개발자 도구, [F5키] 화면 Refresh")
25-
# self.view.devTool.setVisible(True)
26-
17+
def menuUI(self):
2718
openfile_action = QAction('&Open File', self)
2819
openfile_action.setShortcut('Ctrl+O')
2920
openfile_action.setStatusTip('Open files')
@@ -35,22 +26,28 @@ def initUI(self):
3526
openurl_action.triggered.connect(self.onOpenUrl)
3627
# exit_action = QAction(QIcon('exit.png'), "&Exit", self)
3728

29+
quit_action = QAction('&Quit', self)
30+
quit_action.setShortcut('Ctrl+Q')
31+
quit_action.setStatusTip('Exit application')
32+
quit_action.triggered.connect(qApp.quit)
33+
3834
fileMenu = self.menuBar().addMenu('Menu')
3935
fileMenu.addAction(openfile_action)
4036
fileMenu.addAction(openurl_action)
37+
fileMenu.addAction(quit_action)
38+
39+
def initUI(self):
40+
self.setMinimumSize(1024, 640)
41+
self.setWindowTitle("QWebview-plus for Kiwoom")
42+
self.setCentralWidget(self.view)
43+
44+
self.view.statusbar = QStatusBar()
45+
self.setStatusBar(self.view.statusbar)
46+
self.view.statusbar.showMessage("[F4키] 개발자 도구, [F5키] 화면 Refresh")
47+
# self.view.devTool.setVisible(True)
4148

42-
49+
self.menuUI()
4350

44-
# view split
45-
# self.splitter = QSplitter(self)
46-
# self.splitter.setOrientation(Qt.Horizontal)
47-
# layout = QVBoxLayout(self)
48-
# layout.setContentsMargins(0,0,0,0)
49-
# layout.addWidget(self.splitter)
50-
# self.splitter.addWidget(self.view)
51-
# self.splitter.addWidget(self.view.webInspector)
52-
# self.view.webInspector.setVisible(True)
53-
# self.splitter.setSizes([640,640])
5451

5552
def onOpenFile(self, event):
5653
vOpenfilename = QFileDialog.getOpenFileName(self, 'Open File', filter="*.*")
@@ -60,35 +57,16 @@ def onOpenFile(self, event):
6057
window.view.load(QUrl.fromLocalFile(vOpenfilename[0]))
6158

6259
def onOpenUrl(self, event):
63-
vOpenfilename = QFileDialog.getOpenFileName(self, 'Open Url', filter="*.*")
64-
if vOpenfilename == "":
65-
return
66-
if os.path.isfile(vOpenfilename[0]):
67-
window.view.load(QUrl.fromLocalFile(vOpenfilename[0]))
60+
url, okPressed = QInputDialog.getText(self, "Open URL","인터넷 주소를 입력해주세요", QLineEdit.Normal, "")
61+
if okPressed and url != "":
62+
prefix = "" if bool(re.match('^(?:http)s?://', url)) else "http://"
63+
window.view.load(QUrl(prefix + url))
6864

69-
def closeEvent(self, event):
70-
reply = QMessageBox.question(self, 'Message', "QWebview를 종료하시겠습니까?",QMessageBox.Yes | QMessageBox.No, QMessageBox.No)
71-
if reply == QMessageBox.Yes:
72-
event.accept()
73-
else:
74-
event.ignore()
7565

7666
if __name__ == "__main__":
7767
#parsing command line arguments
7868
app = QApplication(sys.argv)
7969
window = Window()
8070
window.show()
8171
sys.exit(app.exec_())
82-
# elif os.path.isfile(opt.file):
83-
# if opt.url:
84-
# prefix = "" if bool(re.match('^(?:http|ftp)s?://', opt.url)) else "http://"
85-
# window.view.load(QUrl(prefix + opt.url))
86-
# window.show()
87-
# sys.exit(app.exec_())
88-
# elif os.path.isfile(opt.file):
89-
# window.view.load(QUrl.fromLocalFile(os.path.join(os.path.dirname( os.path.abspath( __file__ ) ), opt.file)))
90-
# window.show()
91-
# sys.exit(app.exec_())
92-
# else:
93-
# parser.print_help()
94-
# sys.exit()
72+

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
version = "1.0",
66
description = "QWebview supports Kiwoom Open API+ for JavaScript",
77
author = "sculove",
8-
executables = [Executable("main.py")])
8+
executables = [Executable("qwebviewplus.py", base="Win32GUI")])

0 commit comments

Comments
 (0)