Skip to content
This repository has been archived by the owner on Mar 3, 2021. It is now read-only.

Commit

Permalink
v0.1.3 GUI | added change log | include it in readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Redcxx committed Sep 3, 2019
1 parent c2e94af commit 7504446
Show file tree
Hide file tree
Showing 10 changed files with 56 additions and 40 deletions.
4 changes: 2 additions & 2 deletions README.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
Pikax's aim is to provide a simple yet powerful [Pixiv](https://www.pixiv.net/) mass downloading tool
#### [Chinese ver](https://github.com/Redcxx/Pixiv-Crawler/blob/master/README.md)
## GUI
- Login with your Pixiv account
- Use guest login if no account
- [Change log](https://github.com/Redcxx/Pikax/blob/master/gui/change log.txt)
- Login with your Pixiv account or Guest login
- Support download of Rankings, Search and url/id
- [Download here](https://github.com/Redcxx/Pikax/blob/master/gui/dist)
## API
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
Pikax的目的是提供一个使用简单且强大的[Pixiv](https://www.pixiv.net/)\[P站\]批量下载工具。
#### [English ver](https://github.com/Redcxx/Pixiv-Crawler/blob/master/README.en.md)
## 图形界面版
- 用P站账号登录即可
- 无账号可游客登录,无法使用搜索功能
- [日志](https://github.com/Redcxx/Pikax/blob/master/gui/change log.txt)
- 用P站账号或游客登录即可
- 支持下载排行榜,搜索,ID
- [下载](https://github.com/Redcxx/Pikax/blob/master/gui/dist)
## 接口版
Expand Down
16 changes: 11 additions & 5 deletions gui/common.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
import os
import pickle
import sys
import threading
import tkinter as tk
from multiprocessing import Process
from tkinter import END, NORMAL, DISABLED, Text, Entry, TclError

import settings

_screen_lock = threading.Lock()


def go_to_next_screen(src, dest):
pikax_handler = src.pikax_handler
master = src.frame.master
dest(master, pikax_handler)
src.destroy() # destroy after creation to prevent black screen in the middle
global _screen_lock
if _screen_lock.locked():
return
with _screen_lock:
pikax_handler = src.pikax_handler
master = src.frame.master
dest(master, pikax_handler)
src.destroy() # destroy after creation to prevent black screen in the middle


def download(target, args=(), kwargs=()):
Expand Down Expand Up @@ -62,7 +69,6 @@ def __init__(self, canvas, text_id):
def write(self, string):
try:
self.canvas.itemconfigure(self.text_id, text=remove_invalid_chars(string))
self.canvas.configure(scrollregion=self.canvas.bbox('all'))
except TclError as e:
self.canvas.itemconfigure(self.text_id, text=remove_invalid_chars(str(e)))

Expand Down
Binary file not shown.
Binary file added gui/dist/lastest/Pikax 0.1.3.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion gui/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def __init__(self, target, args=(), kwargs=()):

self.grid_height = 9
self.text_font = font.Font(family=settings.DEFAULT_FONT_FAMILY, size=settings.DEFAULT_FONT_SIZE - 2)
self.display_area_height = 16
self.display_area_height = 14
self.display_area_width = 75

self.display_area = self.make_text()
Expand Down
34 changes: 17 additions & 17 deletions gui/id.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import re
import sys
import time
import tkinter as tk
from threading import Thread

import texts
from common import go_to_next_screen
from common import go_to_next_screen, download
from models import PikaxGuiComponent


Expand All @@ -25,29 +26,29 @@ def __init__(self, master, pikax_handler):
super().__init__(master, pikax_handler)

self.grid_width = 20
self.grid_height = 9
self.id_or_url_text_id = self.add_text(text=texts.ID_SCREEN_ID_OR_URL, row=2, column=9, columnspan=2)
self.grid_height = 18
self.id_or_url_text_id = self.add_text(text=texts.ID_SCREEN_ID_OR_URL, row=4, column=9, columnspan=2)

self.id_or_url_entry = self.make_entry(width=40)
self.url_or_entry_id = self.add_widget(widget=self.id_or_url_entry, row=3, column=9, columnspan=2)
self.id_or_url_input = self.make_text(height=10)
self.id_or_url_input_id = self.add_widget(widget=self.id_or_url_input, row=8, column=9, columnspan=2)

# buttons
self.download_button = self.make_button(text=texts.ID_SCREEN_DOWNLOAD)
self.download_button_id = self.add_widget(widget=self.download_button, row=4, column=11)
self.download_button_id = self.add_widget(widget=self.download_button, row=13, column=11)
self.back_button = self.make_button(text=texts.ID_SCREEN_BACK)
self.back_button_id = self.add_widget(widget=self.back_button, row=4, column=8)
self.back_button_id = self.add_widget(widget=self.back_button, row=13, column=8)

self.download_output = self.make_download_output()
self.download_output_id = self.add_widget(widget=self.download_output, row=6, column=9, columnspan=2)
self.redirect_output_to(self.download_output)
self.output = self.make_download_output()
self.output_id = self.add_text(text='', row=15, column=9, columnspan=2, font=self.output_font)
self.redirect_output_to(self.output_id, text_widget=False)

self.download_button.configure(command=self.download_clicked)
self.back_button.configure(command=self.back_clicked)

self.download_thread = None

self.id_or_url_entry.focus_set()
self.download_output.configure(state=tk.DISABLED)
self.id_or_url_input.focus_set()
# self.output.configure(state=tk.DISABLED)
self.frame.pack_configure(expand=True)
self.pack(self.frame)

Expand All @@ -56,13 +57,12 @@ def back_clicked(self):
go_to_next_screen(self, MenuScreen)

def download_clicked(self):
user_input = self.id_or_url_entry.get()
self.canvas.itemconfigure(self.output_id, text='')
user_input = self.id_or_url_input.get(0.0, tk.END)
search_ids = re.findall(r'(?<!\d)\d{8}(?!\d)', user_input, re.S)
if search_ids:
self.download_thread = IDDownloadThread(output_area=self.download_output,
target=self.pikax_handler.download_by_ids,
args=(search_ids,))
self.download_thread.start()
params = {'illust_ids': search_ids}
download(target=self.pikax_handler.download_by_ids, kwargs=params)
else:
sys.stdout.write(texts.ID_SCREEN_NO_ID_FOUND)

Expand Down
9 changes: 8 additions & 1 deletion gui/login.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import settings
import texts
from account import Account
from common import go_to_next_screen, load_from_local, save_to_local
from common import go_to_next_screen, load_from_local, save_to_local, remove_local_file
from lib.pikax.exceptions import PikaxException
from menu import MenuScreen
from models import PikaxGuiComponent
Expand Down Expand Up @@ -147,11 +147,18 @@ def _login(self):
self.pikax_handler.login(username, password)
if self.remember_me_checkbox.get():
self.save_login_credential(username, password)
else:
self.remove_login_credential_if_exists()
go_to_next_screen(src=self, dest=MenuScreen)
except PikaxException as e:
self.login_button.configure(state=tk.NORMAL)
sys.stdout.write(f'{e}')

def remove_login_credential_if_exists(self):
credential_file = settings.LOGIN_CREDENTIAL_FILE
if os.path.isfile(credential_file):
remove_local_file(credential_file)

def save_login_credential(self, username, password):
credential_file = settings.LOGIN_CREDENTIAL_FILE
account = Account(username=username, password=password)
Expand Down
23 changes: 13 additions & 10 deletions gui/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
import texts
from common import crop_to_dimension, get_background_file_path

set_combo_theme = True


class PikaxOptionMenu(tk.OptionMenu):

Expand Down Expand Up @@ -95,6 +93,8 @@ def __init__(self, master, pikax_handler):
self.dropdown_width = 18
self.button_padx = 10
self.button_pady = 2
self.text_padx = 10
self.text_pady = 10

#
# default operations
Expand Down Expand Up @@ -228,7 +228,7 @@ def add_text(self, text, row=0, column=0, rowspan=1, columnspan=1, font=None, co
color = self.display_text_color
if not canvas:
canvas = self.canvas
return canvas.create_text((width, height), text=text, font=font, fill=color)
return canvas.create_text((width, height), text=text, font=font, fill=color, justify=tk.CENTER)

def add_widget(self, widget, row=0, column=0, rowspan=1, columnspan=1):
width, height = self.get_canvas_location(row=row, column=column, rowspan=rowspan, columnspan=columnspan)
Expand Down Expand Up @@ -273,12 +273,12 @@ def make_dropdown(self, default, choices, **kwargs):
dropdown.option_add('*TCombobox*Listbox.Justify', 'center')
return dropdown

def make_entry(self, *args, **kwargs):
def make_entry(self, justify=tk.CENTER, *args, **kwargs):
return tk.Entry(
master=self.frame,
borderwidth=0,
highlightthickness=0,
justify=tk.CENTER,
justify=justify,
bg=self.input_color,
fg=self.input_text_color,
insertbackground=self.cursor_color,
Expand All @@ -287,18 +287,21 @@ def make_entry(self, *args, **kwargs):
**kwargs
)

def make_text(self, *args, **kwargs):
def make_text(self, wrap=tk.WORD, height=1, width=80, state=tk.NORMAL, *args, **kwargs):
text = tk.Text(
master=self.frame,
wrap=tk.WORD,
height=1,
width=80,
state=tk.NORMAL,
wrap=wrap,
height=height,
width=width,
state=state,
highlightthickness=0,
borderwidth=0,
bg=self.input_color,
fg=self.input_text_color,
font=self.output_font,
insertbackground=self.cursor_color,
padx=self.text_padx,
pady=self.text_pady,
*args,
**kwargs
)
Expand Down
4 changes: 2 additions & 2 deletions gui/texts.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@


# ID screen
ID_SCREEN_ID_OR_URL = 'Illustration id(s) or url(s)'
ID_SCREEN_ID_OR_URL = 'Illustration(s) id or url'
ID_SCREEN_DOWNLOAD = 'Download'
ID_SCREEN_BACK = 'Back'
ID_SCREEN_NO_ID_FOUND = 'No valid ID found in input\nshould be 8 digits number'
ID_SCREEN_NO_ID_FOUND = 'No valid ID found in input\nshould be exactly 8 digits number'

# menu screen
MENU_RANK = 'Rank'
Expand Down

0 comments on commit 7504446

Please sign in to comment.