<gh_stars>0
#! /usr/bin/env python
#  -*- coding: utf-8 -*-
#
# GUI module generated by PAGE version 5.3
#  in conjunction with Tcl version 8.6
#    May 26, 2020 02:41:41 PM JST  platform: Windows NT

import tkinter as tk
from tkinter import ttk

import threading
import time
from rmslogin import RakutenRms


class SearchWindow:
    def __init__(self, parent, top, rms):
        self.items = []
        self.rms = rms
        self.parent = parent
        self.search_type_dict = {"商品名": "itemName",
                                 "PC用キャッチコピー": "catchcopy",
                                 "商品管理番号": "itemUrl",
                                 "カタログID": "catalogId",
                                 "全商品ディレクトリID": "genreId",
                                 "価格下限": "itemPriceFrom",
                                 "価格上限": "itemPriceTo",
                                 "倉庫フラグ": "depotFlg",
                                 "商品モバイルフラグ": "itemMobileFlg",
                                 "闇市フラグ": "limitedFlg",
                                 "送料別フラグ": "postageFlg"}

        self.top = top
        self.top.geometry("600x450+650+150")
        self.top.minsize(120, 1)
        self.top.maxsize(3204, 1061)
        self.top.resizable(1, 1)
        self.top.title("検索")

        self.Frame1 = tk.Frame(self.top)
        self.Frame1.place(
            relx=0.017,
            rely=0.022,
            relheight=0.878,
            relwidth=0.958)
        self.Frame1.configure(relief='groove')
        self.Frame1.configure(borderwidth="2")
        self.Frame1.configure(relief="groove")

        self.result_box_var = tk.StringVar()
        self.result_box = tk.Listbox(self.Frame1, listvariable=self.result_box_var, selectmode=tk.EXTENDED)
        self.result_box.place(
            relx=0.017,
            rely=0.203,
            relheight=0.785,
            relwidth=0.963)

        self.keyword_entry = tk.Entry(self.Frame1)
        self.keyword_entry.place(
            relx=0.209,
            rely=0.076,
            height=27,
            relwidth=0.494)

        self.search_button = tk.Button(self.Frame1, command=self.search)
        self.search_button.place(relx=0.73, rely=0.051, height=44, width=67)
        self.search_button.configure(text='''検索''')

        self.search_type_var = tk.StringVar()
        self.search_type = ttk.Combobox(self.Frame1, textvariable=self.search_type_var)
        self.search_type.place(
            relx=0.017,
            rely=0.084,
            relheight=0.053,
            relwidth=0.162)
        self.search_type["values"] = list(self.search_type_dict.keys())
        self.search_type.set("商品名")

        self.next_button = tk.Button(self.Frame1, command=self.nextsearch)
        self.next_button.place(relx=0.87, rely=0.051, height=44, width=67)
        self.next_button.configure(text='''続けて検索''')

        self.enter_button = tk.Button(self.top, command=self.update_item)
        self.enter_button.place(relx=0.683, rely=0.911, height=34, width=67)
        self.enter_button.configure(text='''決定''')

        self.cancel_button = tk.Button(self.top, command=self.destroywindow)
        self.cancel_button.place(relx=0.833, rely=0.911, height=34, width=67)
        self.cancel_button.configure(text='''キャンセル''')

        self.search_num_var = tk.StringVar()
        self.search_num_var.set("0件")
        self.search_num = tk.Label(self.top, textvariable=self.search_num_var)
        self.search_num.place(relx=0.017, rely=0.911, height=31, width=134)

    def update_item(self):
        if self.items:
            self.parent.update_item(self.items)
        self.top.destroy()

    def search(self):
        self.search_thread = threading.Thread(target=self.__search)
        self.search_thread.deamon = True
        self.search_thread.start()
        self.enter_button["state"] = tk.DISABLED
        self.next_button["state"] = tk.DISABLED
        self.search_button["state"] = tk.DISABLED
    
    def __search(self):
        if self.keyword_entry.get():
            chunk_gen = self.rms.search(
                searchkey={
                    self.search_type_dict[self.search_type.get()]: self.keyword_entry.get()})
            for items, result_num, in chunk_gen:
                self.items.extend(items)
                self.search_num_var.set(str(len(self.items)) + "件")

        if self.items:
            self.items = list(set(self.items))
            result_items = [item.find("itemName").text for item in self.items]
            self.result_box.delete(0, tk.END)
            for item in result_items:
                self.result_box.insert(tk.END, item)

        self.enter_button["state"] = tk.NORMAL
        self.next_button["state"] = tk.NORMAL
        self.search_button["state"] = tk.NORMAL

    def nextsearch(self):
        if self.items and self.keyword_entry.get():
            self.items = self.rms.nextsearch(self.items, searchkey={
                self.search_type_dict[self.search_type.get()]: self.keyword_entry.get()})

            result_items = [item.find("itemName").text for item in self.items]
            self.result_box.delete(0, tk.END)
            for item in result_items:
                self.result_box.insert(tk.END, item)

            self.search_num_var.set(str(len(self.items)) + "件")

    def destroywindow(self):
        self.top.destroy()


class MainWindow:
    def __init__(self, rms, top):
        self.rms = rms
        self.items = []
        self.toggles = {}
        self.entries = {}
        self.selected = {}
        self.update_flag = False

        top.geometry("889x909+708+81")
        top.minsize(120, 1)
        top.maxsize(3204, 1041)
        top.resizable(1, 1)
        top.title("rakuten-item-update")

        self.menubar = tk.Menu(top)
        top.configure(menu=self.menubar)

        self.menubar.add_command(
            label="検索", command=self.create_search_window)

        self.Frame1 = tk.Frame(top)
        self.Frame1.place(relx=0.0, rely=0.0, relheight=1.0, relwidth=1.0)
        self.Frame1.configure(relief='groove')
        self.Frame1.configure(borderwidth="2")
        self.Frame1.configure(relief="groove")
        self.__item_name()
        self.__sale_time()
        self.__catchcopy()
        self.__mb_catchcopy()
        self.__tax_rate()
        self.__tax_flag()
        self.__delivery_set_id()
        self.__postage_flag()
        self.__daibiki_flag()
        self.__catalog_caption()
        self.__smart_caption()
        self.__display_caption()
        self.__depot_flag()
        self.__limited_flag()
        self.__item_box()
        self.__item_updates()

        for k, sel in self.selected.items():
            sel["values"] = [v for k, v in self.rms.config.settings[k]["options"].items()]

    def create_search_window(self):
        SearchWindow(parent=self, top=tk.Toplevel(), rms=self.rms)

    def update_item(self, items):
        self.items = items
        if self.items:
            result_items = [item.find("itemName").text for item in self.items]
            self.result_box.delete(0, tk.END)
            for item in result_items:
                self.result_box.insert(tk.END, item)
            self.item_num_label_var.set(str(len(self.items)) + "件")
    
    def exclusion_items(self):
        if self.items:
            selection = sorted(list(self.result_box.curselection()), reverse=True)
            for sel in selection:
                self.result_box.delete(sel)
                del self.items[sel]
            self.update_item(self.items)
        
    def update_rms_items(self):
        self.update_item_thread = threading.Thread(target=self.__update_rms_items)
        self.update_item_thread.start()
        self.update_flag = True
        self.update_button["state"] = tk.DISABLED

    def __update_rms_items(self):
        self.update_flag = True
        for item in self.items:
            if not self.update_flag:
                break
            for k, toggle in self.toggles.items():
                toggle_var = toggle.get()
                self.rms.config.settings[k]["toggle"] = toggle_var

                if toggle_var:
                    value = self.entries[k]
                    if type(value) is list:
                        self.rms.config.settings[k]["insert"] = [
                            self.entries[k][0].get(), self.entries[k][1].get()]
                        self.rms.config.settings[k]["replace"] = [
                            self.entries[k][2].get(), self.entries[k][3].get()]
                    else:
                        if self.rms.config.settings[k]["type"] == "select":
                            options = {v: k for k, v in self.rms.config.settings[k]["options"].items()}
                            self.rms.config.settings[k]["value"] = options[self.entries[k].get()]
                        else:
                            self.rms.config.settings[k]["value"] = self.entries[k].get()

                    self.rms.update(item.find("itemUrl").text)
            
        self.update_button["state"] = tk.NORMAL

    def cancel_updates(self):
        self.update_flag = False

    def __item_name(self, toggle=False):

        self.Frame2 = tk.Frame(self.Frame1)
        self.Frame2.place(relx=0.0, rely=0.0, relheight=0.087, relwidth=0.649)
        self.Frame2.configure(relief='groove')
        self.Frame2.configure(borderwidth="2")
        self.Frame2.configure(relief="groove")

        self.Label1 = tk.Label(self.Frame2)
        self.Label1.place(relx=0.069, rely=0.101, height=64, width=83)
        self.Label1.configure(text='''商品名''')
        self.Label1.configure(wraplength="50")

        self.item_name_insert_1 = tk.Entry(self.Frame2)
        self.item_name_insert_1.place(
            relx=0.31, rely=0.152, height=27, relwidth=0.267)

        self.item_name_insert_2 = tk.Entry(self.Frame2)
        self.item_name_insert_2.place(
            relx=0.716, rely=0.152, height=27, relwidth=0.267)

        self.Label2 = tk.Label(self.Frame2)
        self.Label2.place(relx=0.208, rely=0.152, height=22, width=43)
        self.Label2.configure(text='''挿入前''')

        self.Label3 = tk.Label(self.Frame2)
        self.Label3.place(relx=0.622, rely=0.152, height=22, width=43)
        self.Label3.configure(text='''挿入後''')

        self.item_name_replace_1 = tk.Entry(self.Frame2)
        self.item_name_replace_1.place(
            relx=0.31, rely=0.557, height=27, relwidth=0.267)

        self.item_name_replace_2 = tk.Entry(self.Frame2)
        self.item_name_replace_2.place(
            relx=0.716, rely=0.557, height=27, relwidth=0.267)

        self.Label4 = tk.Label(self.Frame2)
        self.Label4.place(relx=0.208, rely=0.557, height=20, width=43)
        self.Label4.configure(text='''置換前''')

        self.Label5 = tk.Label(self.Frame2)
        self.Label5.place(relx=0.622, rely=0.557, height=20, width=43)
        self.Label5.configure(text='''置換後''')

        self.item_name_toggle_var = tk.BooleanVar()
        self.item_name_toggle_var.set(toggle)
        self.item_name_toggle = tk.Checkbutton(self.Frame2)
        self.item_name_toggle.place(
            relx=0.029,
            rely=0.316,
            relheight=0.392,
            relwidth=0.071)
        self.item_name_toggle.configure(justify='left')
        self.item_name_toggle.configure(variable=self.item_name_toggle_var)

        self.toggles["item_name"] = self.item_name_toggle_var
        self.entries["item_name"] = [
            self.item_name_insert_1,
            self.item_name_insert_2,
            self.item_name_replace_1,
            self.item_name_replace_2]

    def __sale_time(
            self,
            toggle=False):
        self.Frame3 = tk.Frame(self.Frame1)
        self.Frame3.place(
            relx=0.0,
            rely=0.509,
            relheight=0.099,
            relwidth=0.649)
        self.Frame3.configure(relief='groove')
        self.Frame3.configure(borderwidth="2")
        self.Frame3.configure(relief="groove")

        self.Label6 = tk.Label(self.Frame3, text="販売終了日時")
        self.Label6.place(relx=0.087, rely=0.1, height=29, width=99)

        self.sale_time_toggle_var = tk.BooleanVar()
        self.sale_time_toggle_var.set(toggle)
        self.sale_time_toggle = tk.Checkbutton(
            self.Frame3, variable=self.sale_time_toggle_var, justify="left")
        self.sale_time_toggle.place(
            relx=0.029,
            rely=0.311,
            relheight=0.4,
            relwidth=0.071)

        self.Label7 = tk.Label(self.Frame3, text="販売終了日時")
        self.Label7.place(relx=0.087, rely=0.522, height=29, width=99)

        self.s_time_year_var = tk.StringVar()
        self.s_time_year = ttk.Combobox(
            self.Frame3, textvariable=self.s_time_year_var)
        self.s_time_year.place(
            relx=0.295,
            rely=0.211,
            relheight=0.211,
            relwidth=0.125)

        self.s_time_month_var = tk.StringVar()
        self.s_time_month = ttk.Combobox(
            self.Frame3, textvariable=self.s_time_month_var)
        self.s_time_month.place(
            relx=0.466,
            rely=0.211,
            relheight=0.211,
            relwidth=0.075)

        self.s_time_day_var = tk.StringVar()
        self.s_time_day = ttk.Combobox(
            self.Frame3, textvariable=self.s_time_day_var)
        self.s_time_day.place(
            relx=0.588,
            rely=0.211,
            relheight=0.211,
            relwidth=0.075)

        self.s_time_hour_var = tk.StringVar()
        self.s_time_hour = ttk.Combobox(
            self.Frame3, textvariable=self.s_time_hour_var)
        self.s_time_hour.place(
            relx=0.709,
            rely=0.211,
            relheight=0.211,
            relwidth=0.075)

        self.s_time_min_var = tk.StringVar()
        self.s_time_min = ttk.Combobox(
            self.Frame3, textvariable=self.s_time_min_var)
        self.s_time_min.place(
            relx=0.83,
            rely=0.211,
            relheight=0.211,
            relwidth=0.075)

        self.Label8 = tk.Label(self.Frame3, text="年")
        self.Label8.place(relx=0.433, rely=0.211, height=19, width=14)

        self.Label9 = tk.Label(self.Frame3, text="月")
        self.Label9.place(relx=0.555, rely=0.211, height=19, width=14)

        self.Label10 = tk.Label(self.Frame3, text="日")
        self.Label10.place(relx=0.674, rely=0.211, height=19, width=14)

        self.Label11 = tk.Label(self.Frame3, text="時")
        self.Label11.place(relx=0.795, rely=0.211, height=19, width=14)

        self.Label12 = tk.Label(self.Frame3, text="分")
        self.Label12.place(relx=0.917, rely=0.211, height=19, width=14)

        self.e_time_year_var = tk.StringVar()
        self.e_time_year = ttk.Combobox(
            self.Frame3, textvariable=self.e_time_year_var)
        self.e_time_year.place(
            relx=0.295,
            rely=0.622,
            relheight=0.222,
            relwidth=0.125)

        self.e_time_month_var = tk.StringVar()
        self.e_time_month = ttk.Combobox(
            self.Frame3, textvariable=self.e_time_month_var)
        self.e_time_month.place(
            relx=0.466,
            rely=0.622,
            relheight=0.222,
            relwidth=0.075)

        self.e_time_day_var = tk.StringVar()
        self.e_time_day = ttk.Combobox(
            self.Frame3, textvariable=self.e_time_day_var)
        self.e_time_day.place(
            relx=0.588,
            rely=0.622,
            relheight=0.222,
            relwidth=0.075)

        self.e_time_hour_var = tk.StringVar()
        self.e_time_hour = ttk.Combobox(
            self.Frame3, textvariable=self.e_time_hour_var)
        self.e_time_hour.place(
            relx=0.709,
            rely=0.622,
            relheight=0.222,
            relwidth=0.075)

        self.e_time_min_var = tk.StringVar()
        self.e_time_min = ttk.Combobox(
            self.Frame3, textvariable=self.e_time_min_var)
        self.e_time_min.place(
            relx=0.83,
            rely=0.622,
            relheight=0.222,
            relwidth=0.075)

        self.Label13 = tk.Label(self.Frame3, text="年")
        self.Label13.place(relx=0.433, rely=0.622, height=20, width=14)
        self.Label14 = tk.Label(self.Frame3, text="月")
        self.Label14.place(relx=0.555, rely=0.622, height=20, width=14)
        self.Label15 = tk.Label(self.Frame3, text="日")
        self.Label15.place(relx=0.674, rely=0.622, height=20, width=14)
        self.Label16 = tk.Label(self.Frame3, text="時")
        self.Label16.place(relx=0.795, rely=0.622, height=20, width=14)
        self.Label17 = tk.Label(self.Frame3, text="分")
        self.Label17.place(relx=0.917, rely=0.622, height=20, width=14)

        self.toggles["sale_stime_year"] = self.sale_time_toggle_var
        self.toggles["sale_stime_month"] = self.sale_time_toggle_var
        self.toggles["sale_stime_day"] = self.sale_time_toggle_var
        self.toggles["sale_stime_hour"] = self.sale_time_toggle_var
        self.toggles["sale_stime_min"] = self.sale_time_toggle_var
        self.toggles["sale_etime_year"] = self.sale_time_toggle_var
        self.toggles["sale_etime_month"] = self.sale_time_toggle_var
        self.toggles["sale_etime_day"] = self.sale_time_toggle_var
        self.toggles["sale_etime_hour"] = self.sale_time_toggle_var
        self.toggles["sale_etime_min"] = self.sale_time_toggle_var

        self.selected["sale_stime_year"] = self.s_time_year
        self.selected["sale_stime_month"] = self.s_time_month
        self.selected["sale_stime_day"] = self.s_time_day
        self.selected["sale_stime_hour"] = self.s_time_hour
        self.selected["sale_stime_min"] = self.s_time_min
        self.selected["sale_etime_year"] = self.e_time_year
        self.selected["sale_etime_month"] = self.e_time_month
        self.selected["sale_etime_day"] = self.e_time_day
        self.selected["sale_etime_hour"] = self.e_time_hour
        self.selected["sale_etime_min"] = self.e_time_min

        self.entries["sale_stime_year"] = self.s_time_year_var
        self.entries["sale_stime_month"] = self.s_time_month_var
        self.entries["sale_stime_day"] = self.s_time_day_var
        self.entries["sale_stime_hour"] = self.s_time_hour_var
        self.entries["sale_stime_min"] = self.s_time_min_var
        self.entries["sale_etime_year"] = self.e_time_year_var
        self.entries["sale_etime_month"] = self.e_time_month_var
        self.entries["sale_etime_day"] = self.e_time_day_var
        self.entries["sale_etime_hour"] = self.e_time_hour_var
        self.entries["sale_etime_min"] = self.e_time_min_var

    def __catchcopy(self, toggle=False):
        self.Frame2_7 = tk.Frame(self.Frame1)
        self.Frame2_7.place(
            relx=0.0,
            rely=0.085,
            relheight=0.087,
            relwidth=0.649)
        self.Frame2_7.configure(relief='groove')
        self.Frame2_7.configure(borderwidth="2")
        self.Frame2_7.configure(relief="groove")

        self.Label1_8 = tk.Label(
            self.Frame2_7,
            text="PC用キャッチコピー",
            wraplength="50")
        self.Label1_8.place(relx=0.069, rely=0.101, height=64, width=83)

        self.catchcopy_insert_1 = tk.Entry(self.Frame2_7)
        self.catchcopy_insert_1.place(
            relx=0.31, rely=0.152, height=27, relwidth=0.267)

        self.catchcopy_insert_2 = tk.Entry(self.Frame2_7)
        self.catchcopy_insert_2.place(
            relx=0.716, rely=0.152, height=27, relwidth=0.267)

        self.Label2_4 = tk.Label(self.Frame2_7, text="挿入前")
        self.Label2_4.place(relx=0.208, rely=0.152, height=22, width=43)

        self.Label3_5 = tk.Label(self.Frame2_7, text="挿入後")
        self.Label3_5.place(relx=0.622, rely=0.152, height=22, width=43)

        self.catchcopy_replace_1 = tk.Entry(self.Frame2_7)
        self.catchcopy_replace_1.place(
            relx=0.31, rely=0.557, height=27, relwidth=0.267)

        self.catchcopy_replace_2 = tk.Entry(self.Frame2_7)
        self.catchcopy_replace_2.place(
            relx=0.716, rely=0.557, height=27, relwidth=0.267)

        self.Label4_4 = tk.Label(self.Frame2_7, text="置換前")
        self.Label4_4.place(relx=0.208, rely=0.557, height=20, width=43)

        self.Label5_5 = tk.Label(self.Frame2_7, text="置換後")
        self.Label5_5.place(relx=0.622, rely=0.557, height=20, width=43)

        self.catchcopy_toggle_var = tk.BooleanVar()
        self.catchcopy_toggle_var.set(toggle)

        self.catchcopy_toggle = tk.Checkbutton(
            self.Frame2_7, variable=self.catchcopy_toggle_var)
        self.catchcopy_toggle.place(
            relx=0.029,
            rely=0.316,
            relheight=0.392,
            relwidth=0.071)

        self.toggles["catch_copy"] = self.catchcopy_toggle_var
        self.entries["catch_copy"] = [
            self.catchcopy_insert_1,
            self.catchcopy_insert_2,
            self.catchcopy_replace_1,
            self.catchcopy_replace_2]

    def __mb_catchcopy(self, toggle=False):
        self.Frame2_8 = tk.Frame(self.Frame1)
        self.Frame2_8.place(
            relx=0.0,
            rely=0.169,
            relheight=0.087,
            relwidth=0.649)
        self.Frame2_8.configure(relief='groove')
        self.Frame2_8.configure(borderwidth="2")
        self.Frame2_8.configure(relief="groove")

        self.Label1_9 = tk.Label(self.Frame2_8)
        self.Label1_9.place(relx=0.069, rely=0.101, height=64, width=83)
        self.Label1_9.configure(text='''モバイル用キャッチコピー''')
        self.Label1_9.configure(wraplength="50")

        self.mb_catchcopy_insert_1 = tk.Entry(self.Frame2_8)
        self.mb_catchcopy_insert_1.place(
            relx=0.31, rely=0.152, height=27, relwidth=0.267)

        self.mb_catchcopy_insert_2 = tk.Entry(self.Frame2_8)
        self.mb_catchcopy_insert_2.place(
            relx=0.716, rely=0.152, height=27, relwidth=0.267)

        self.Label2_5 = tk.Label(self.Frame2_8)
        self.Label2_5.place(relx=0.208, rely=0.152, height=22, width=43)
        self.Label2_5.configure(text='''挿入前''')

        self.Label3_6 = tk.Label(self.Frame2_8)
        self.Label3_6.place(relx=0.622, rely=0.152, height=22, width=43)
        self.Label3_6.configure(text='''挿入後''')

        self.mb_catchcopy_replace_1 = tk.Entry(self.Frame2_8)
        self.mb_catchcopy_replace_1.place(
            relx=0.31, rely=0.557, height=27, relwidth=0.267)

        self.mb_catchcopy_replace_2 = tk.Entry(self.Frame2_8)
        self.mb_catchcopy_replace_2.place(
            relx=0.716, rely=0.557, height=27, relwidth=0.267)

        self.Label4_5 = tk.Label(self.Frame2_8)
        self.Label4_5.place(relx=0.208, rely=0.557, height=20, width=43)
        self.Label4_5.configure(text='''置換前''')

        self.Label5_6 = tk.Label(self.Frame2_8)
        self.Label5_6.place(relx=0.622, rely=0.557, height=20, width=43)
        self.Label5_6.configure(text='''置換後''')

        self.mb_catchcopy_toggle_var = tk.BooleanVar()
        self.mb_catchcopy_toggle_var.set(toggle)
        self.mb_catchcopy_toggle = tk.Checkbutton(
            self.Frame2_8, variable=self.mb_catchcopy_toggle_var)
        self.mb_catchcopy_toggle.place(
            relx=0.029,
            rely=0.316,
            relheight=0.392,
            relwidth=0.071)

        self.toggles["mobile_catch_copy"] = self.mb_catchcopy_toggle_var
        self.entries["mobile_catch_copy"] = [
            self.mb_catchcopy_insert_1,
            self.mb_catchcopy_insert_2,
            self.mb_catchcopy_replace_1,
            self.mb_catchcopy_replace_2]

    def __tax_rate(self, toggle=False):
        self.Frame2_9 = tk.Frame(self.Frame1)
        self.Frame2_9.place(
            relx=0.0,
            rely=0.254,
            relheight=0.052,
            relwidth=0.649)
        self.Frame2_9.configure(relief='groove')
        self.Frame2_9.configure(borderwidth="2")
        self.Frame2_9.configure(relief="groove")

        self.Label1_10 = tk.Label(self.Frame2_9)
        self.Label1_10.place(relx=0.069, rely=0.106, height=38, width=83)
        self.Label1_10.configure(text='''消費税率''')
        self.Label1_10.configure(wraplength="50")

        self.tax_rate_toggle_var = tk.BooleanVar()
        self.tax_rate_toggle_var.set(toggle)
        self.tax_rate_toggle = tk.Checkbutton(
            self.Frame2_9, variable=self.tax_rate_toggle_var)
        self.tax_rate_toggle.place(
            relx=0.029,
            rely=0.319,
            relheight=0.383,
            relwidth=0.071)

        self.tax_rate_var = tk.StringVar()
        self.tax_rate = ttk.Combobox(
            self.Frame2_9, textvariable=self.tax_rate_var)
        self.tax_rate.place(
            relx=0.312,
            rely=0.213,
            relheight=0.447,
            relwidth=0.248)

        self.toggles["tax_rate"] = self.tax_rate_toggle_var
        self.selected["tax_rate"] = self.tax_rate
        self.entries["tax_rate"] = self.tax_rate_var

    def __tax_flag(self, toggle=False):
        self.Frame2_10 = tk.Frame(self.Frame1)
        self.Frame2_10.place(
            relx=0.0,
            rely=0.304,
            relheight=0.054,
            relwidth=0.649)
        self.Frame2_10.configure(relief='groove')
        self.Frame2_10.configure(borderwidth="2")
        self.Frame2_10.configure(relief="groove")

        self.Label1_11 = tk.Label(self.Frame2_10)
        self.Label1_11.place(relx=0.069, rely=0.102, height=40, width=83)
        self.Label1_11.configure(text='''消費税''')
        self.Label1_11.configure(wraplength="50")

        self.tax_flag_toggle_var = tk.BooleanVar()
        self.tax_flag_toggle_var.set(toggle)
        self.tax_flag_toggle = tk.Checkbutton(
            self.Frame2_10, variable=self.tax_flag_toggle_var)
        self.tax_flag_toggle.place(
            relx=0.029,
            rely=0.306,
            relheight=0.408,
            relwidth=0.071)

        self.tax_flag_var = tk.IntVar()
        self.tax_flag_1 = tk.Radiobutton(
            self.Frame2_10, variable=self.tax_flag_var, value=0)
        self.tax_flag_1.place(
            relx=0.312,
            rely=0.204,
            relheight=0.531,
            relwidth=0.135)
        self.tax_flag_1.configure(text='''消費税別''')

        self.tax_flag_2 = tk.Radiobutton(
            self.Frame2_10, variable=self.tax_flag_var, value=1)
        self.tax_flag_2.place(
            relx=0.624,
            rely=0.204,
            relheight=0.551,
            relwidth=0.135)
        self.tax_flag_2.configure(text='''消費税込''')

        self.toggles["tax_flag"] = self.tax_flag_toggle_var
        self.entries["tax_flag"] = self.tax_flag_var

    def __delivery_set_id(self, toggle=False):
        self.Frame2_11 = tk.Frame(self.Frame1)
        self.Frame2_11.place(
            relx=0.0,
            rely=0.355,
            relheight=0.054,
            relwidth=0.649)
        self.Frame2_11.configure(relief='groove')
        self.Frame2_11.configure(borderwidth="2")
        self.Frame2_11.configure(relief="groove")

        self.Label1_12 = tk.Label(self.Frame2_11)
        self.Label1_12.place(relx=0.069, rely=0.102, height=40, width=83)
        self.Label1_12.configure(text='''配送方法セット''')
        self.Label1_12.configure(wraplength="50")

        self.delivery_set_id_var = tk.StringVar()
        self.delivery_set_id = ttk.Combobox(
            self.Frame2_11, textvariable=self.delivery_set_id_var)
        self.delivery_set_id.place(
            relx=0.312,
            rely=0.204,
            relheight=0.449,
            relwidth=0.248)

        self.delivery_set_id_toggle_var = tk.BooleanVar()
        self.delivery_set_id_toggle_var.set(toggle)
        self.delivery_set_id_toggle = tk.Checkbutton(
            self.Frame2_11, variable=self.delivery_set_id_toggle_var)
        self.delivery_set_id_toggle.place(
            relx=0.029,
            rely=0.306,
            relheight=0.408,
            relwidth=0.071)

        self.toggles["delivery_set_id"] = self.delivery_set_id_toggle_var
        self.selected["delivery_set_id"] = self.delivery_set_id
        self.entries["delivery_set_id"] = self.delivery_set_id_var

    def __postage_flag(self, toggle=False):
        self.Frame2_11 = tk.Frame(self.Frame1)
        self.Frame2_11.place(
            relx=0.0,
            rely=0.407,
            relheight=0.053,
            relwidth=0.649)
        self.Frame2_11.configure(relief='groove')
        self.Frame2_11.configure(borderwidth="2")
        self.Frame2_11.configure(relief="groove")

        self.Label1_12 = tk.Label(self.Frame2_11)
        self.Label1_12.place(relx=0.069, rely=0.104, height=39, width=83)
        self.Label1_12.configure(text='''送料''')
        self.Label1_12.configure(wraplength="50")

        self.postage_flag_toggle_var = tk.BooleanVar()
        self.postage_flag_toggle_var.set(toggle)
        self.postage_flag_toggle = tk.Checkbutton(
            self.Frame2_11, variable=self.postage_flag_toggle_var)
        self.postage_flag_toggle.place(
            relx=0.029,
            rely=0.313,
            relheight=0.396,
            relwidth=0.071)

        self.postage_flag_var = tk.IntVar()
        self.postage_flag_1 = tk.Radiobutton(
            self.Frame2_11, variable=self.postage_flag_var, value=0)
        self.postage_flag_1.place(
            relx=0.295,
            rely=0.208,
            relheight=0.521,
            relwidth=0.153)
        self.postage_flag_1.configure(text='''送料別''')

        self.postage_flag_2 = tk.Radiobutton(
            self.Frame2_11, variable=self.postage_flag_var, value=1)
        self.postage_flag_2.place(
            relx=0.624,
            rely=0.208,
            relheight=0.542,
            relwidth=0.135)
        self.postage_flag_2.configure(text='''送料無料''')

        self.toggles["postage_flag"] = self.postage_flag_toggle_var
        self.entries["postage_flag"] = self.postage_flag_var

    def __daibiki_flag(self, toggle=False):
        self.Frame2_4 = tk.Frame(self.Frame1)
        self.Frame2_4.place(
            relx=0.0,
            rely=0.458,
            relheight=0.054,
            relwidth=0.649)
        self.Frame2_4.configure(relief='groove')
        self.Frame2_4.configure(borderwidth="2")
        self.Frame2_4.configure(relief="groove")

        self.Label1_5 = tk.Label(self.Frame2_4)
        self.Label1_5.place(relx=0.069, rely=0.102, height=40, width=83)
        self.Label1_5.configure(text='''代引料''')
        self.Label1_5.configure(wraplength="50")

        self.daibiki_flag_toggle_var = tk.BooleanVar()
        self.daibiki_flag_toggle_var.set(toggle)
        self.daibiki_flag_toggle = tk.Checkbutton(
            self.Frame2_4, variable=self.daibiki_flag_toggle_var)
        self.daibiki_flag_toggle.place(
            relx=0.029,
            rely=0.306,
            relheight=0.408,
            relwidth=0.071)

        self.daibiki_flag_var = tk.IntVar()
        self.daibiki_flag_1 = tk.Radiobutton(
            self.Frame2_4, variable=self.daibiki_flag_var, value=0)
        self.daibiki_flag_1.place(
            relx=0.295,
            rely=0.204,
            relheight=0.551,
            relwidth=0.17)
        self.daibiki_flag_1.configure(text="代引料別")

        self.daibiki_flag_2 = tk.Radiobutton(
            self.Frame2_4, variable=self.daibiki_flag_var, value=1)
        self.daibiki_flag_2.place(
            relx=0.607,
            rely=0.204,
            relheight=0.551,
            relwidth=0.172)
        self.daibiki_flag_2.configure(text="代引料込")

        self.toggles["daibiki_flag"] = self.daibiki_flag_toggle_var
        self.entries["daibiki_flag"] = self.daibiki_flag_var

    def __catalog_caption(self, toggle=False):
        self.Frame2_4 = tk.Frame(self.Frame1)
        self.Frame2_4.place(
            relx=0.0,
            rely=0.606,
            relheight=0.088,
            relwidth=0.649)
        self.Frame2_4.configure(relief='groove')
        self.Frame2_4.configure(borderwidth="2")
        self.Frame2_4.configure(relief="groove")

        self.Label1_5 = tk.Label(self.Frame2_4)
        self.Label1_5.place(relx=0.069, rely=0.1, height=65, width=93)
        self.Label1_5.configure(text='''PC用商品説明文''')
        self.Label1_5.configure(wraplength="50")

        self.catalog_caption_insert_1 = tk.Entry(self.Frame2_4)
        self.catalog_caption_insert_1.place(
            relx=0.31, rely=0.15, height=27, relwidth=0.267)

        self.catalog_caption_insert_2 = tk.Entry(self.Frame2_4)
        self.catalog_caption_insert_2.place(
            relx=0.716, rely=0.15, height=27, relwidth=0.267)

        self.Label2_4 = tk.Label(self.Frame2_4)
        self.Label2_4.place(relx=0.208, rely=0.15, height=22, width=43)
        self.Label2_4.configure(text='''挿入前''')

        self.Label3_5 = tk.Label(self.Frame2_4)
        self.Label3_5.place(relx=0.622, rely=0.15, height=22, width=43)
        self.Label3_5.configure(text='''挿入後''')

        self.catalog_caption_replace_1 = tk.Entry(self.Frame2_4)
        self.catalog_caption_replace_1.place(
            relx=0.31, rely=0.55, height=27, relwidth=0.267)

        self.catalog_caption_replace_2 = tk.Entry(self.Frame2_4)
        self.catalog_caption_replace_2.place(
            relx=0.716, rely=0.55, height=27, relwidth=0.267)

        self.Label4_4 = tk.Label(self.Frame2_4)
        self.Label4_4.place(relx=0.208, rely=0.55, height=21, width=43)
        self.Label4_4.configure(text='''置換前''')

        self.Label5_5 = tk.Label(self.Frame2_4)
        self.Label5_5.place(relx=0.622, rely=0.55, height=21, width=43)
        self.Label5_5.configure(text='''置換後''')

        self.catalog_caption_toggle_var = tk.BooleanVar()
        self.catalog_caption_toggle_var.set(toggle)
        self.catalog_caption_toggle = tk.Checkbutton(
            self.Frame2_4, variable=self.catalog_caption_toggle_var)
        self.catalog_caption_toggle.place(
            relx=0.029, rely=0.313, relheight=0.4, relwidth=0.071)

        self.toggles["catalog_caption"] = self.catalog_caption_toggle_var
        self.entries["catalog_caption"] = [
            self.catalog_caption_insert_1,
            self.catalog_caption_insert_2,
            self.catalog_caption_replace_1,
            self.catalog_caption_replace_2]

    def __smart_caption(self, toggle=False):
        self.Frame2_5 = tk.Frame(self.Frame1)
        self.Frame2_5.place(
            relx=0.0,
            rely=0.692,
            relheight=0.087,
            relwidth=0.649)
        self.Frame2_5.configure(relief='groove')
        self.Frame2_5.configure(borderwidth="2")
        self.Frame2_5.configure(relief="groove")

        self.Label1_6 = tk.Label(self.Frame2_5)
        self.Label1_6.place(relx=0.069, rely=0.101, height=64, width=93)
        self.Label1_6.configure(text='''スマートフォン用商品説明文''')
        self.Label1_6.configure(wraplength="50")

        self.smart_caption_insert_1 = tk.Entry(self.Frame2_5)
        self.smart_caption_insert_1.place(
            relx=0.31, rely=0.152, height=27, relwidth=0.267)

        self.smart_caption_insert_2 = tk.Entry(self.Frame2_5)
        self.smart_caption_insert_2.place(
            relx=0.716, rely=0.152, height=27, relwidth=0.267)

        self.Label2_5 = tk.Label(self.Frame2_5)
        self.Label2_5.place(relx=0.208, rely=0.152, height=22, width=43)
        self.Label2_5.configure(text='''挿入前''')

        self.Label3_6 = tk.Label(self.Frame2_5)
        self.Label3_6.place(relx=0.622, rely=0.152, height=22, width=43)
        self.Label3_6.configure(text='''挿入後''')

        self.smart_caption_replace_1 = tk.Entry(self.Frame2_5)
        self.smart_caption_replace_1.place(
            relx=0.31, rely=0.557, height=27, relwidth=0.267)

        self.smart_caption_replace_2 = tk.Entry(self.Frame2_5)
        self.smart_caption_replace_2.place(
            relx=0.716, rely=0.557, height=27, relwidth=0.267)

        self.Label4_5 = tk.Label(self.Frame2_5)
        self.Label4_5.place(relx=0.208, rely=0.557, height=20, width=43)
        self.Label4_5.configure(text='''置換前''')

        self.Label5_6 = tk.Label(self.Frame2_5)
        self.Label5_6.place(relx=0.622, rely=0.557, height=20, width=43)
        self.Label5_6.configure(text='''置換後''')

        self.smart_caption_toggle_var = tk.BooleanVar()
        self.smart_caption_toggle_var.set(toggle)
        self.smart_caption_toggle = tk.Checkbutton(
            self.Frame2_5, variable=self.smart_caption_toggle_var)
        self.smart_caption_toggle.place(
            relx=0.029,
            rely=0.316,
            relheight=0.392,
            relwidth=0.071)

        self.toggles["smart_caption"] = self.smart_caption_toggle_var
        self.entries["smart_caption"] = [
            self.smart_caption_insert_1,
            self.smart_caption_insert_2,
            self.smart_caption_replace_1,
            self.smart_caption_replace_2]

    def __display_caption(self, toggle=False):
        self.Frame2_6 = tk.Frame(self.Frame1)
        self.Frame2_6.place(
            relx=0.0,
            rely=0.777,
            relheight=0.087,
            relwidth=0.649)
        self.Frame2_6.configure(relief='groove')
        self.Frame2_6.configure(borderwidth="2")
        self.Frame2_6.configure(relief="groove")

        self.Label1_7 = tk.Label(self.Frame2_6)
        self.Label1_7.place(relx=0.069, rely=0.101, height=64, width=93)
        self.Label1_7.configure(text='''PC用販売説明文''')
        self.Label1_7.configure(wraplength="50")

        self.display_caption_insert_1 = tk.Entry(self.Frame2_6)
        self.display_caption_insert_1.place(
            relx=0.31, rely=0.152, height=27, relwidth=0.267)

        self.display_caption_insert_2 = tk.Entry(self.Frame2_6)
        self.display_caption_insert_2.place(
            relx=0.716, rely=0.152, height=27, relwidth=0.267)

        self.Label2_6 = tk.Label(self.Frame2_6)
        self.Label2_6.place(relx=0.208, rely=0.152, height=22, width=43)
        self.Label2_6.configure(text='''挿入前''')

        self.Label3_7 = tk.Label(self.Frame2_6)
        self.Label3_7.place(relx=0.622, rely=0.152, height=22, width=43)
        self.Label3_7.configure(text='''挿入後''')

        self.display_caption_replace_1 = tk.Entry(self.Frame2_6)
        self.display_caption_replace_1.place(
            relx=0.31, rely=0.557, height=27, relwidth=0.267)

        self.display_caption_replace_2 = tk.Entry(self.Frame2_6)
        self.display_caption_replace_2.place(
            relx=0.716, rely=0.557, height=27, relwidth=0.267)

        self.Label4_6 = tk.Label(self.Frame2_6)
        self.Label4_6.place(relx=0.208, rely=0.557, height=20, width=43)
        self.Label4_6.configure(text='''置換前''')

        self.Label5_7 = tk.Label(self.Frame2_6)
        self.Label5_7.place(relx=0.622, rely=0.557, height=20, width=43)
        self.Label5_7.configure(text='''置換後''')

        self.display_caption_toggle_var = tk.BooleanVar()
        self.display_caption_toggle_var.set(toggle)
        self.display_caption_toggle = tk.Checkbutton(
            self.Frame2_6, variable=self.display_caption_toggle_var)
        self.display_caption_toggle.place(
            relx=0.029, rely=0.316, relheight=0.392, relwidth=0.071)

        self.toggles["display_caption"] = self.display_caption_toggle_var
        self.entries["display_caption"] = [
            self.display_caption_insert_1,
            self.display_caption_insert_2,
            self.display_caption_replace_1,
            self.display_caption_replace_2]

    def __depot_flag(self, toggle=False):
        self.Frame2_5 = tk.Frame(self.Frame1)
        self.Frame2_5.place(
            relx=0.0,
            rely=0.861,
            relheight=0.054,
            relwidth=0.649)
        self.Frame2_5.configure(relief='groove')
        self.Frame2_5.configure(borderwidth="2")
        self.Frame2_5.configure(relief="groove")

        self.Label1_6 = tk.Label(self.Frame2_5)
        self.Label1_6.place(relx=0.069, rely=0.102, height=40, width=83)
        self.Label1_6.configure(text='''倉庫指定''')
        self.Label1_6.configure(wraplength="50")

        self.depot_flag_toggle_var = tk.BooleanVar()
        self.depot_flag_toggle_var.set(toggle)
        self.depot_flag_toggle = tk.Checkbutton(
            self.Frame2_5, variable=self.depot_flag_toggle_var)
        self.depot_flag_toggle.place(
            relx=0.029,
            rely=0.306,
            relheight=0.408,
            relwidth=0.071)

        self.depot_flag_var = tk.IntVar()
        self.depot_flag_1 = tk.Radiobutton(
            self.Frame2_5, variable=self.depot_flag_var, value=0)
        self.depot_flag_1.place(
            relx=0.295,
            rely=0.204,
            relheight=0.551,
            relwidth=0.153)
        self.depot_flag_1.configure(text='''販売中''')

        self.depot_flag_2 = tk.Radiobutton(
            self.Frame2_5, variable=self.depot_flag_var, value=1)
        self.depot_flag_2.place(
            relx=0.605,
            rely=0.204,
            relheight=0.551,
            relwidth=0.206)
        self.depot_flag_2.configure(text='''倉庫に入れる''')

        self.toggles["depot_flag"] = self.depot_flag_toggle_var
        self.entries["depot_flag"] = self.depot_flag_var

    def __limited_flag(self, toggle=False):
        self.Frame2_6 = tk.Frame(self.Frame1)
        self.Frame2_6.place(
            relx=0.0,
            rely=0.913,
            relheight=0.053,
            relwidth=0.649)
        self.Frame2_6.configure(relief='groove')
        self.Frame2_6.configure(borderwidth="2")
        self.Frame2_6.configure(relief="groove")

        self.Label1_7 = tk.Label(self.Frame2_6)
        self.Label1_7.place(relx=0.069, rely=0.109, height=37, width=83)
        self.Label1_7.configure(text='''サーチ非表示''')
        self.Label1_7.configure(wraplength="50")

        self.limited_flag_toggle_var = tk.BooleanVar()
        self.limited_flag_toggle_var.set(toggle)
        self.limited_flag_toggle = tk.Checkbutton(self.Frame2_6, variable=self.limited_flag_toggle_var)
        self.limited_flag_toggle.place(
            relx=0.029,
            rely=0.304,
            relheight=0.413,
            relwidth=0.071)

        self.limited_flag_checkbtn_var = tk.BooleanVar()
        self.limited_flag_checkbtn = tk.Checkbutton(self.Frame2_6, variable=self.limited_flag_checkbtn_var)
        self.limited_flag_checkbtn.place(
            relx=0.277, rely=0.217, relheight=0.522, relwidth=0.277)
        self.limited_flag_checkbtn.configure(text='''サーチ非表示にする''')

        self.toggles["limited_flag"] = self.limited_flag_toggle_var
        self.entries["limited_flag"] = self.limited_flag_checkbtn_var

    def __item_box(self):
        self.result_box_var = tk.StringVar()
        self.result_box = tk.Listbox(
            self.Frame1,
            listvariable=self.result_box_var,
            selectmode=tk.EXTENDED)
        self.result_box.place(
            relx=0.652,
            rely=0.056,
            relheight=0.776,
            relwidth=0.341)

        self.item_num_label_var = tk.StringVar()
        self.item_num_label_var.set("0件")
        self.item_num_label = tk.Label(self.Frame1, textvariable=self.item_num_label_var)
        self.item_num_label.place(relx=0.945, rely=0.022, height=27, width=43)

        self.exclusion_button = tk.Button(
            self.Frame1, command=self.exclusion_items)
        self.exclusion_button.place(relx=0.844, rely=0.844, height=44, width=127)
        self.exclusion_button.configure(text='''除外''')

    def __item_updates(self):
        self.update_button = tk.Button(self.Frame1, command=self.update_rms_items)
        self.update_button.place(relx=0.664, rely=0.934, height=44, width=137)
        self.update_button.configure(text='''更新''')

        self.cancel_button = tk.Button(self.Frame1, command=self.cancel_updates)
        self.cancel_button.place(relx=0.844, rely=0.934, height=44, width=127)
        self.cancel_button.configure(text='''停止''')


if __name__ == '__main__':
    rms = RakutenRms()
    rms.login()
    rms.updateShopsettings()

    root = tk.Tk()
    toplevel = MainWindow(rms=rms, top=root)
    root.mainloop()

#! /usr/bin/env python
#  -*- coding: utf-8 -*-
#
# GUI module generated by PAGE version 5.3
#  in conjunction with Tcl version 8.6
#    May 26, 2020 02:41:41 PM JST  platform: Windows NT

import tkinter as tk
from tkinter import ttk

import threading
import time
from rmslogin import RakutenRms


class SearchWindow:
    def __init__(self, parent, top, rms):
        self.items = []
        self.rms = rms
        self.parent = parent
        self.search_type_dict = {"商品名": "itemName",
                                 "PC用キャッチコピー": "catchcopy",
                                 "商品管理番号": "itemUrl",
                                 "カタログID": "catalogId",
                                 "全商品ディレクトリID": "genreId",
                                 "価格下限": "itemPriceFrom",
                                 "価格上限": "itemPriceTo",
                                 "倉庫フラグ": "depotFlg",
                                 "商品モバイルフラグ": "itemMobileFlg",
                                 "闇市フラグ": "limitedFlg",
                                 "送料別フラグ": "postageFlg"}

        self.top = top
        self.top.geometry("600x450+650+150")
        self.top.minsize(120, 1)
        self.top.maxsize(3204, 1061)
        self.top.resizable(1, 1)
        self.top.title("検索")

        self.Frame1 = tk.Frame(self.top)
        self.Frame1.place(
            relx=0.017,
            rely=0.022,
            relheight=0.878,
            relwidth=0.958)
        self.Frame1.configure(relief='groove')
        self.Frame1.configure(borderwidth="2")
        self.Frame1.configure(relief="groove")

        self.result_box_var = tk.StringVar()
        self.result_box = tk.Listbox(self.Frame1, listvariable=self.result_box_var, selectmode=tk.EXTENDED)
        self.result_box.place(
            relx=0.017,
            rely=0.203,
            relheight=0.785,
            relwidth=0.963)

        self.keyword_entry = tk.Entry(self.Frame1)
        self.keyword_entry.place(
            relx=0.209,
            rely=0.076,
            height=27,
            relwidth=0.494)

        self.search_button = tk.Button(self.Frame1, command=self.search)
        self.search_button.place(relx=0.73, rely=0.051, height=44, width=67)
        self.search_button.configure(text='''検索''')

        self.search_type_var = tk.StringVar()
        self.search_type = ttk.Combobox(self.Frame1, textvariable=self.search_type_var)
        self.search_type.place(
            relx=0.017,
            rely=0.084,
            relheight=0.053,
            relwidth=0.162)
        self.search_type["values"] = list(self.search_type_dict.keys())
        self.search_type.set("商品名")

        self.next_button = tk.Button(self.Frame1, command=self.nextsearch)
        self.next_button.place(relx=0.87, rely=0.051, height=44, width=67)
        self.next_button.configure(text='''続けて検索''')

        self.enter_button = tk.Button(self.top, command=self.update_item)
        self.enter_button.place(relx=0.683, rely=0.911, height=34, width=67)
        self.enter_button.configure(text='''決定''')

        self.cancel_button = tk.Button(self.top, command=self.destroywindow)
        self.cancel_button.place(relx=0.833, rely=0.911, height=34, width=67)
        self.cancel_button.configure(text='''キャンセル''')

        self.search_num_var = tk.StringVar()
        self.search_num_var.set("0件")
        self.search_num = tk.Label(self.top, textvariable=self.search_num_var)
        self.search_num.place(relx=0.017, rely=0.911, height=31, width=134)

    def update_item(self):
        if self.items:
            self.parent.update_item(self.items)
        self.top.destroy()

    def search(self):
        self.search_thread = threading.Thread(target=self.__search)
        self.search_thread.deamon = True
        self.search_thread.start()
        self.enter_button["state"] = tk.DISABLED
        self.next_button["state"] = tk.DISABLED
        self.search_button["state"] = tk.DISABLED
    
    def __search(self):
        if self.keyword_entry.get():
            chunk_gen = self.rms.search(
                searchkey={
                    self.search_type_dict[self.search_type.get()]: self.keyword_entry.get()})
            for items, result_num, in chunk_gen:
                self.items.extend(items)
                self.search_num_var.set(str(len(self.items)) + "件")

        if self.items:
            self.items = list(set(self.items))
            result_items = [item.find("itemName").text for item in self.items]
            self.result_box.delete(0, tk.END)
            for item in result_items:
                self.result_box.insert(tk.END, item)

        self.enter_button["state"] = tk.NORMAL
        self.next_button["state"] = tk.NORMAL
        self.search_button["state"] = tk.NORMAL

    def nextsearch(self):
        if self.items and self.keyword_entry.get():
            self.items = self.rms.nextsearch(self.items, searchkey={
                self.search_type_dict[self.search_type.get()]: self.keyword_entry.get()})

            result_items = [item.find("itemName").text for item in self.items]
            self.result_box.delete(0, tk.END)
            for item in result_items:
                self.result_box.insert(tk.END, item)

            self.search_num_var.set(str(len(self.items)) + "件")

    def destroywindow(self):
        self.top.destroy()


class MainWindow:
    def __init__(self, rms, top):
        self.rms = rms
        self.items = []
        self.toggles = {}
        self.entries = {}
        self.selected = {}
        self.update_flag = False

        top.geometry("889x909+708+81")
        top.minsize(120, 1)
        top.maxsize(3204, 1041)
        top.resizable(1, 1)
        top.title("rakuten-item-update")

        self.menubar = tk.Menu(top)
        top.configure(menu=self.menubar)

        self.menubar.add_command(
            label="検索", command=self.create_search_window)

        self.Frame1 = tk.Frame(top)
        self.Frame1.place(relx=0.0, rely=0.0, relheight=1.0, relwidth=1.0)
        self.Frame1.configure(relief='groove')
        self.Frame1.configure(borderwidth="2")
        self.Frame1.configure(relief="groove")
        self.__item_name()
        self.__sale_time()
        self.__catchcopy()
        self.__mb_catchcopy()
        self.__tax_rate()
        self.__tax_flag()
        self.__delivery_set_id()
        self.__postage_flag()
        self.__daibiki_flag()
        self.__catalog_caption()
        self.__smart_caption()
        self.__display_caption()
        self.__depot_flag()
        self.__limited_flag()
        self.__item_box()
        self.__item_updates()

        for k, sel in self.selected.items():
            sel["values"] = [v for k, v in self.rms.config.settings[k]["options"].items()]

    def create_search_window(self):
        SearchWindow(parent=self, top=tk.Toplevel(), rms=self.rms)

    def update_item(self, items):
        self.items = items
        if self.items:
            result_items = [item.find("itemName").text for item in self.items]
            self.result_box.delete(0, tk.END)
            for item in result_items:
                self.result_box.insert(tk.END, item)
            self.item_num_label_var.set(str(len(self.items)) + "件")
    
    def exclusion_items(self):
        if self.items:
            selection = sorted(list(self.result_box.curselection()), reverse=True)
            for sel in selection:
                self.result_box.delete(sel)
                del self.items[sel]
            self.update_item(self.items)
        
    def update_rms_items(self):
        self.update_item_thread = threading.Thread(target=self.__update_rms_items)
        self.update_item_thread.start()
        self.update_flag = True
        self.update_button["state"] = tk.DISABLED

    def __update_rms_items(self):
        self.update_flag = True
        for item in self.items:
            if not self.update_flag:
                break
            for k, toggle in self.toggles.items():
                toggle_var = toggle.get()
                self.rms.config.settings[k]["toggle"] = toggle_var

                if toggle_var:
                    value = self.entries[k]
                    if type(value) is list:
                        self.rms.config.settings[k]["insert"] = [
                            self.entries[k][0].get(), self.entries[k][1].get()]
                        self.rms.config.settings[k]["replace"] = [
                            self.entries[k][2].get(), self.entries[k][3].get()]
                    else:
                        if self.rms.config.settings[k]["type"] == "select":
                            options = {v: k for k, v in self.rms.config.settings[k]["options"].items()}
                            self.rms.config.settings[k]["value"] = options[self.entries[k].get()]
                        else:
                            self.rms.config.settings[k]["value"] = self.entries[k].get()

                    self.rms.update(item.find("itemUrl").text)
            
        self.update_button["state"] = tk.NORMAL

    def cancel_updates(self):
        self.update_flag = False

    def __item_name(self, toggle=False):

        self.Frame2 = tk.Frame(self.Frame1)
        self.Frame2.place(relx=0.0, rely=0.0, relheight=0.087, relwidth=0.649)
        self.Frame2.configure(relief='groove')
        self.Frame2.configure(borderwidth="2")
        self.Frame2.configure(relief="groove")

        self.Label1 = tk.Label(self.Frame2)
        self.Label1.place(relx=0.069, rely=0.101, height=64, width=83)
        self.Label1.configure(text='''商品名''')
        self.Label1.configure(wraplength="50")

        self.item_name_insert_1 = tk.Entry(self.Frame2)
        self.item_name_insert_1.place(
            relx=0.31, rely=0.152, height=27, relwidth=0.267)

        self.item_name_insert_2 = tk.Entry(self.Frame2)
        self.item_name_insert_2.place(
            relx=0.716, rely=0.152, height=27, relwidth=0.267)

        self.Label2 = tk.Label(self.Frame2)
        self.Label2.place(relx=0.208, rely=0.152, height=22, width=43)
        self.Label2.configure(text='''挿入前''')

        self.Label3 = tk.Label(self.Frame2)
        self.Label3.place(relx=0.622, rely=0.152, height=22, width=43)
        self.Label3.configure(text='''挿入後''')

        self.item_name_replace_1 = tk.Entry(self.Frame2)
        self.item_name_replace_1.place(
            relx=0.31, rely=0.557, height=27, relwidth=0.267)

        self.item_name_replace_2 = tk.Entry(self.Frame2)
        self.item_name_replace_2.place(
            relx=0.716, rely=0.557, height=27, relwidth=0.267)

        self.Label4 = tk.Label(self.Frame2)
        self.Label4.place(relx=0.208, rely=0.557, height=20, width=43)
        self.Label4.configure(text='''置換前''')

        self.Label5 = tk.Label(self.Frame2)
        self.Label5.place(relx=0.622, rely=0.557, height=20, width=43)
        self.Label5.configure(text='''置換後''')

        self.item_name_toggle_var = tk.BooleanVar()
        self.item_name_toggle_var.set(toggle)
        self.item_name_toggle = tk.Checkbutton(self.Frame2)
        self.item_name_toggle.place(
            relx=0.029,
            rely=0.316,
            relheight=0.392,
            relwidth=0.071)
        self.item_name_toggle.configure(justify='left')
        self.item_name_toggle.configure(variable=self.item_name_toggle_var)

        self.toggles["item_name"] = self.item_name_toggle_var
        self.entries["item_name"] = [
            self.item_name_insert_1,
            self.item_name_insert_2,
            self.item_name_replace_1,
            self.item_name_replace_2]

    def __sale_time(
            self,
            toggle=False):
        self.Frame3 = tk.Frame(self.Frame1)
        self.Frame3.place(
            relx=0.0,
            rely=0.509,
            relheight=0.099,
            relwidth=0.649)
        self.Frame3.configure(relief='groove')
        self.Frame3.configure(borderwidth="2")
        self.Frame3.configure(relief="groove")

        self.Label6 = tk.Label(self.Frame3, text="販売終了日時")
        self.Label6.place(relx=0.087, rely=0.1, height=29, width=99)

        self.sale_time_toggle_var = tk.BooleanVar()
        self.sale_time_toggle_var.set(toggle)
        self.sale_time_toggle = tk.Checkbutton(
            self.Frame3, variable=self.sale_time_toggle_var, justify="left")
        self.sale_time_toggle.place(
            relx=0.029,
            rely=0.311,
            relheight=0.4,
            relwidth=0.071)

        self.Label7 = tk.Label(self.Frame3, text="販売終了日時")
        self.Label7.place(relx=0.087, rely=0.522, height=29, width=99)

        self.s_time_year_var = tk.StringVar()
        self.s_time_year = ttk.Combobox(
            self.Frame3, textvariable=self.s_time_year_var)
        self.s_time_year.place(
            relx=0.295,
            rely=0.211,
            relheight=0.211,
            relwidth=0.125)

        self.s_time_month_var = tk.StringVar()
        self.s_time_month = ttk.Combobox(
            self.Frame3, textvariable=self.s_time_month_var)
        self.s_time_month.place(
            relx=0.466,
            rely=0.211,
            relheight=0.211,
            relwidth=0.075)

        self.s_time_day_var = tk.StringVar()
        self.s_time_day = ttk.Combobox(
            self.Frame3, textvariable=self.s_time_day_var)
        self.s_time_day.place(
            relx=0.588,
            rely=0.211,
            relheight=0.211,
            relwidth=0.075)

        self.s_time_hour_var = tk.StringVar()
        self.s_time_hour = ttk.Combobox(
            self.Frame3, textvariable=self.s_time_hour_var)
        self.s_time_hour.place(
            relx=0.709,
            rely=0.211,
            relheight=0.211,
            relwidth=0.075)

        self.s_time_min_var = tk.StringVar()
        self.s_time_min = ttk.Combobox(
            self.Frame3, textvariable=self.s_time_min_var)
        self.s_time_min.place(
            relx=0.83,
            rely=0.211,
            relheight=0.211,
            relwidth=0.075)

        self.Label8 = tk.Label(self.Frame3, text="年")
        self.Label8.place(relx=0.433, rely=0.211, height=19, width=14)

        self.Label9 = tk.Label(self.Frame3, text="月")
        self.Label9.place(relx=0.555, rely=0.211, height=19, width=14)

        self.Label10 = tk.Label(self.Frame3, text="日")
        self.Label10.place(relx=0.674, rely=0.211, height=19, width=14)

        self.Label11 = tk.Label(self.Frame3, text="時")
        self.Label11.place(relx=0.795, rely=0.211, height=19, width=14)

        self.Label12 = tk.Label(self.Frame3, text="分")
        self.Label12.place(relx=0.917, rely=0.211, height=19, width=14)

        self.e_time_year_var = tk.StringVar()
        self.e_time_year = ttk.Combobox(
            self.Frame3, textvariable=self.e_time_year_var)
        self.e_time_year.place(
            relx=0.295,
            rely=0.622,
            relheight=0.222,
            relwidth=0.125)

        self.e_time_month_var = tk.StringVar()
        self.e_time_month = ttk.Combobox(
            self.Frame3, textvariable=self.e_time_month_var)
        self.e_time_month.place(
            relx=0.466,
            rely=0.622,
            relheight=0.222,
            relwidth=0.075)

        self.e_time_day_var = tk.StringVar()
        self.e_time_day = ttk.Combobox(
            self.Frame3, textvariable=self.e_time_day_var)
        self.e_time_day.place(
            relx=0.588,
            rely=0.622,
            relheight=0.222,
            relwidth=0.075)

        self.e_time_hour_var = tk.StringVar()
        self.e_time_hour = ttk.Combobox(
            self.Frame3, textvariable=self.e_time_hour_var)
        self.e_time_hour.place(
            relx=0.709,
            rely=0.622,
            relheight=0.222,
            relwidth=0.075)

        self.e_time_min_var = tk.StringVar()
        self.e_time_min = ttk.Combobox(
            self.Frame3, textvariable=self.e_time_min_var)
        self.e_time_min.place(
            relx=0.83,
            rely=0.622,
            relheight=0.222,
            relwidth=0.075)

        self.Label13 = tk.Label(self.Frame3, text="年")
        self.Label13.place(relx=0.433, rely=0.622, height=20, width=14)
        self.Label14 = tk.Label(self.Frame3, text="月")
        self.Label14.place(relx=0.555, rely=0.622, height=20, width=14)
        self.Label15 = tk.Label(self.Frame3, text="日")
        self.Label15.place(relx=0.674, rely=0.622, height=20, width=14)
        self.Label16 = tk.Label(self.Frame3, text="時")
        self.Label16.place(relx=0.795, rely=0.622, height=20, width=14)
        self.Label17 = tk.Label(self.Frame3, text="分")
        self.Label17.place(relx=0.917, rely=0.622, height=20, width=14)

        self.toggles["sale_stime_year"] = self.sale_time_toggle_var
        self.toggles["sale_stime_month"] = self.sale_time_toggle_var
        self.toggles["sale_stime_day"] = self.sale_time_toggle_var
        self.toggles["sale_stime_hour"] = self.sale_time_toggle_var
        self.toggles["sale_stime_min"] = self.sale_time_toggle_var
        self.toggles["sale_etime_year"] = self.sale_time_toggle_var
        self.toggles["sale_etime_month"] = self.sale_time_toggle_var
        self.toggles["sale_etime_day"] = self.sale_time_toggle_var
        self.toggles["sale_etime_hour"] = self.sale_time_toggle_var
        self.toggles["sale_etime_min"] = self.sale_time_toggle_var

        self.selected["sale_stime_year"] = self.s_time_year
        self.selected["sale_stime_month"] = self.s_time_month
        self.selected["sale_stime_day"] = self.s_time_day
        self.selected["sale_stime_hour"] = self.s_time_hour
        self.selected["sale_stime_min"] = self.s_time_min
        self.selected["sale_etime_year"] = self.e_time_year
        self.selected["sale_etime_month"] = self.e_time_month
        self.selected["sale_etime_day"] = self.e_time_day
        self.selected["sale_etime_hour"] = self.e_time_hour
        self.selected["sale_etime_min"] = self.e_time_min

        self.entries["sale_stime_year"] = self.s_time_year_var
        self.entries["sale_stime_month"] = self.s_time_month_var
        self.entries["sale_stime_day"] = self.s_time_day_var
        self.entries["sale_stime_hour"] = self.s_time_hour_var
        self.entries["sale_stime_min"] = self.s_time_min_var
        self.entries["sale_etime_year"] = self.e_time_year_var
        self.entries["sale_etime_month"] = self.e_time_month_var
        self.entries["sale_etime_day"] = self.e_time_day_var
        self.entries["sale_etime_hour"] = self.e_time_hour_var
        self.entries["sale_etime_min"] = self.e_time_min_var

    def __catchcopy(self, toggle=False):
        self.Frame2_7 = tk.Frame(self.Frame1)
        self.Frame2_7.place(
            relx=0.0,
            rely=0.085,
            relheight=0.087,
            relwidth=0.649)
        self.Frame2_7.configure(relief='groove')
        self.Frame2_7.configure(borderwidth="2")
        self.Frame2_7.configure(relief="groove")

        self.Label1_8 = tk.Label(
            self.Frame2_7,
            text="PC用キャッチコピー",
            wraplength="50")
        self.Label1_8.place(relx=0.069, rely=0.101, height=64, width=83)

        self.catchcopy_insert_1 = tk.Entry(self.Frame2_7)
        self.catchcopy_insert_1.place(
            relx=0.31, rely=0.152, height=27, relwidth=0.267)

        self.catchcopy_insert_2 = tk.Entry(self.Frame2_7)
        self.catchcopy_insert_2.place(
            relx=0.716, rely=0.152, height=27, relwidth=0.267)

        self.Label2_4 = tk.Label(self.Frame2_7, text="挿入前")
        self.Label2_4.place(relx=0.208, rely=0.152, height=22, width=43)

        self.Label3_5 = tk.Label(self.Frame2_7, text="挿入後")
        self.Label3_5.place(relx=0.622, rely=0.152, height=22, width=43)

        self.catchcopy_replace_1 = tk.Entry(self.Frame2_7)
        self.catchcopy_replace_1.place(
            relx=0.31, rely=0.557, height=27, relwidth=0.267)

        self.catchcopy_replace_2 = tk.Entry(self.Frame2_7)
        self.catchcopy_replace_2.place(
            relx=0.716, rely=0.557, height=27, relwidth=0.267)

        self.Label4_4 = tk.Label(self.Frame2_7, text="置換前")
        self.Label4_4.place(relx=0.208, rely=0.557, height=20, width=43)

        self.Label5_5 = tk.Label(self.Frame2_7, text="置換後")
        self.Label5_5.place(relx=0.622, rely=0.557, height=20, width=43)

        self.catchcopy_toggle_var = tk.BooleanVar()
        self.catchcopy_toggle_var.set(toggle)

        self.catchcopy_toggle = tk.Checkbutton(
            self.Frame2_7, variable=self.catchcopy_toggle_var)
        self.catchcopy_toggle.place(
            relx=0.029,
            rely=0.316,
            relheight=0.392,
            relwidth=0.071)

        self.toggles["catch_copy"] = self.catchcopy_toggle_var
        self.entries["catch_copy"] = [
            self.catchcopy_insert_1,
            self.catchcopy_insert_2,
            self.catchcopy_replace_1,
            self.catchcopy_replace_2]

    def __mb_catchcopy(self, toggle=False):
        self.Frame2_8 = tk.Frame(self.Frame1)
        self.Frame2_8.place(
            relx=0.0,
            rely=0.169,
            relheight=0.087,
            relwidth=0.649)
        self.Frame2_8.configure(relief='groove')
        self.Frame2_8.configure(borderwidth="2")
        self.Frame2_8.configure(relief="groove")

        self.Label1_9 = tk.Label(self.Frame2_8)
        self.Label1_9.place(relx=0.069, rely=0.101, height=64, width=83)
        self.Label1_9.configure(text='''モバイル用キャッチコピー''')
        self.Label1_9.configure(wraplength="50")

        self.mb_catchcopy_insert_1 = tk.Entry(self.Frame2_8)
        self.mb_catchcopy_insert_1.place(
            relx=0.31, rely=0.152, height=27, relwidth=0.267)

        self.mb_catchcopy_insert_2 = tk.Entry(self.Frame2_8)
        self.mb_catchcopy_insert_2.place(
            relx=0.716, rely=0.152, height=27, relwidth=0.267)

        self.Label2_5 = tk.Label(self.Frame2_8)
        self.Label2_5.place(relx=0.208, rely=0.152, height=22, width=43)
        self.Label2_5.configure(text='''挿入前''')

        self.Label3_6 = tk.Label(self.Frame2_8)
        self.Label3_6.place(relx=0.622, rely=0.152, height=22, width=43)
        self.Label3_6.configure(text='''挿入後''')

        self.mb_catchcopy_replace_1 = tk.Entry(self.Frame2_8)
        self.mb_catchcopy_replace_1.place(
            relx=0.31, rely=0.557, height=27, relwidth=0.267)

        self.mb_catchcopy_replace_2 = tk.Entry(self.Frame2_8)
        self.mb_catchcopy_replace_2.place(
            relx=0.716, rely=0.557, height=27, relwidth=0.267)

        self.Label4_5 = tk.Label(self.Frame2_8)
        self.Label4_5.place(relx=0.208, rely=0.557, height=20, width=43)
        self.Label4_5.configure(text='''置換前''')

        self.Label5_6 = tk.Label(self.Frame2_8)
        self.Label5_6.place(relx=0.622, rely=0.557, height=20, width=43)
        self.Label5_6.configure(text='''置換後''')

        self.mb_catchcopy_toggle_var = tk.BooleanVar()
        self.mb_catchcopy_toggle_var.set(toggle)
        self.mb_catchcopy_toggle = tk.Checkbutton(
            self.Frame2_8, variable=self.mb_catchcopy_toggle_var)
        self.mb_catchcopy_toggle.place(
            relx=0.029,
            rely=0.316,
            relheight=0.392,
            relwidth=0.071)

        self.toggles["mobile_catch_copy"] = self.mb_catchcopy_toggle_var
        self.entries["mobile_catch_copy"] = [
            self.mb_catchcopy_insert_1,
            self.mb_catchcopy_insert_2,
            self.mb_catchcopy_replace_1,
            self.mb_catchcopy_replace_2]

    def __tax_rate(self, toggle=False):
        self.Frame2_9 = tk.Frame(self.Frame1)
        self.Frame2_9.place(
            relx=0.0,
            rely=0.254,
            relheight=0.052,
            relwidth=0.649)
        self.Frame2_9.configure(relief='groove')
        self.Frame2_9.configure(borderwidth="2")
        self.Frame2_9.configure(relief="groove")

        self.Label1_10 = tk.Label(self.Frame2_9)
        self.Label1_10.place(relx=0.069, rely=0.106, height=38, width=83)
        self.Label1_10.configure(text='''消費税率''')
        self.Label1_10.configure(wraplength="50")

        self.tax_rate_toggle_var = tk.BooleanVar()
        self.tax_rate_toggle_var.set(toggle)
        self.tax_rate_toggle = tk.Checkbutton(
            self.Frame2_9, variable=self.tax_rate_toggle_var)
        self.tax_rate_toggle.place(
            relx=0.029,
            rely=0.319,
            relheight=0.383,
            relwidth=0.071)

        self.tax_rate_var = tk.StringVar()
        self.tax_rate = ttk.Combobox(
            self.Frame2_9, textvariable=self.tax_rate_var)
        self.tax_rate.place(
            relx=0.312,
            rely=0.213,
            relheight=0.447,
            relwidth=0.248)

        self.toggles["tax_rate"] = self.tax_rate_toggle_var
        self.selected["tax_rate"] = self.tax_rate
        self.entries["tax_rate"] = self.tax_rate_var

    def __tax_flag(self, toggle=False):
        self.Frame2_10 = tk.Frame(self.Frame1)
        self.Frame2_10.place(
            relx=0.0,
            rely=0.304,
            relheight=0.054,
            relwidth=0.649)
        self.Frame2_10.configure(relief='groove')
        self.Frame2_10.configure(borderwidth="2")
        self.Frame2_10.configure(relief="groove")

        self.Label1_11 = tk.Label(self.Frame2_10)
        self.Label1_11.place(relx=0.069, rely=0.102, height=40, width=83)
        self.Label1_11.configure(text='''消費税''')
        self.Label1_11.configure(wraplength="50")

        self.tax_flag_toggle_var = tk.BooleanVar()
        self.tax_flag_toggle_var.set(toggle)
        self.tax_flag_toggle = tk.Checkbutton(
            self.Frame2_10, variable=self.tax_flag_toggle_var)
        self.tax_flag_toggle.place(
            relx=0.029,
            rely=0.306,
            relheight=0.408,
            relwidth=0.071)

        self.tax_flag_var = tk.IntVar()
        self.tax_flag_1 = tk.Radiobutton(
            self.Frame2_10, variable=self.tax_flag_var, value=0)
        self.tax_flag_1.place(
            relx=0.312,
            rely=0.204,
            relheight=0.531,
            relwidth=0.135)
        self.tax_flag_1.configure(text='''消費税別''')

        self.tax_flag_2 = tk.Radiobutton(
            self.Frame2_10, variable=self.tax_flag_var, value=1)
        self.tax_flag_2.place(
            relx=0.624,
            rely=0.204,
            relheight=0.551,
            relwidth=0.135)
        self.tax_flag_2.configure(text='''消費税込''')

        self.toggles["tax_flag"] = self.tax_flag_toggle_var
        self.entries["tax_flag"] = self.tax_flag_var

    def __delivery_set_id(self, toggle=False):
        self.Frame2_11 = tk.Frame(self.Frame1)
        self.Frame2_11.place(
            relx=0.0,
            rely=0.355,
            relheight=0.054,
            relwidth=0.649)
        self.Frame2_11.configure(relief='groove')
        self.Frame2_11.configure(borderwidth="2")
        self.Frame2_11.configure(relief="groove")

        self.Label1_12 = tk.Label(self.Frame2_11)
        self.Label1_12.place(relx=0.069, rely=0.102, height=40, width=83)
        self.Label1_12.configure(text='''配送方法セット''')
        self.Label1_12.configure(wraplength="50")

        self.delivery_set_id_var = tk.StringVar()
        self.delivery_set_id = ttk.Combobox(
            self.Frame2_11, textvariable=self.delivery_set_id_var)
        self.delivery_set_id.place(
            relx=0.312,
            rely=0.204,
            relheight=0.449,
            relwidth=0.248)

        self.delivery_set_id_toggle_var = tk.BooleanVar()
        self.delivery_set_id_toggle_var.set(toggle)
        self.delivery_set_id_toggle = tk.Checkbutton(
            self.Frame2_11, variable=self.delivery_set_id_toggle_var)
        self.delivery_set_id_toggle.place(
            relx=0.029,
            rely=0.306,
            relheight=0.408,
            relwidth=0.071)

        self.toggles["delivery_set_id"] = self.delivery_set_id_toggle_var
        self.selected["delivery_set_id"] = self.delivery_set_id
        self.entries["delivery_set_id"] = self.delivery_set_id_var

    def __postage_flag(self, toggle=False):
        self.Frame2_11 = tk.Frame(self.Frame1)
        self.Frame2_11.place(
            relx=0.0,
            rely=0.407,
            relheight=0.053,
            relwidth=0.649)
        self.Frame2_11.configure(relief='groove')
        self.Frame2_11.configure(borderwidth="2")
        self.Frame2_11.configure(relief="groove")

        self.Label1_12 = tk.Label(self.Frame2_11)
        self.Label1_12.place(relx=0.069, rely=0.104, height=39, width=83)
        self.Label1_12.configure(text='''送料''')
        self.Label1_12.configure(wraplength="50")

        self.postage_flag_toggle_var = tk.BooleanVar()
        self.postage_flag_toggle_var.set(toggle)
        self.postage_flag_toggle = tk.Checkbutton(
            self.Frame2_11, variable=self.postage_flag_toggle_var)
        self.postage_flag_toggle.place(
            relx=0.029,
            rely=0.313,
            relheight=0.396,
            relwidth=0.071)

        self.postage_flag_var = tk.IntVar()
        self.postage_flag_1 = tk.Radiobutton(
            self.Frame2_11, variable=self.postage_flag_var, value=0)
        self.postage_flag_1.place(
            relx=0.295,
            rely=0.208,
            relheight=0.521,
            relwidth=0.153)
        self.postage_flag_1.configure(text='''送料別''')

        self.postage_flag_2 = tk.Radiobutton(
            self.Frame2_11, variable=self.postage_flag_var, value=1)
        self.postage_flag_2.place(
            relx=0.624,
            rely=0.208,
            relheight=0.542,
            relwidth=0.135)
        self.postage_flag_2.configure(text='''送料無料''')

        self.toggles["postage_flag"] = self.postage_flag_toggle_var
        self.entries["postage_flag"] = self.postage_flag_var

    def __daibiki_flag(self, toggle=False):
        self.Frame2_4 = tk.Frame(self.Frame1)
        self.Frame2_4.place(
            relx=0.0,
            rely=0.458,
            relheight=0.054,
            relwidth=0.649)
        self.Frame2_4.configure(relief='groove')
        self.Frame2_4.configure(borderwidth="2")
        self.Frame2_4.configure(relief="groove")

        self.Label1_5 = tk.Label(self.Frame2_4)
        self.Label1_5.place(relx=0.069, rely=0.102, height=40, width=83)
        self.Label1_5.configure(text='''代引料''')
        self.Label1_5.configure(wraplength="50")

        self.daibiki_flag_toggle_var = tk.BooleanVar()
        self.daibiki_flag_toggle_var.set(toggle)
        self.daibiki_flag_toggle = tk.Checkbutton(
            self.Frame2_4, variable=self.daibiki_flag_toggle_var)
        self.daibiki_flag_toggle.place(
            relx=0.029,
            rely=0.306,
            relheight=0.408,
            relwidth=0.071)

        self.daibiki_flag_var = tk.IntVar()
        self.daibiki_flag_1 = tk.Radiobutton(
            self.Frame2_4, variable=self.daibiki_flag_var, value=0)
        self.daibiki_flag_1.place(
            relx=0.295,
            rely=0.204,
            relheight=0.551,
            relwidth=0.17)
        self.daibiki_flag_1.configure(text="代引料別")

        self.daibiki_flag_2 = tk.Radiobutton(
            self.Frame2_4, variable=self.daibiki_flag_var, value=1)
        self.daibiki_flag_2.place(
            relx=0.607,
            rely=0.204,
            relheight=0.551,
            relwidth=0.172)
        self.daibiki_flag_2.configure(text="代引料込")

        self.toggles["daibiki_flag"] = self.daibiki_flag_toggle_var
        self.entries["daibiki_flag"] = self.daibiki_flag_var

    def __catalog_caption(self, toggle=False):
        self.Frame2_4 = tk.Frame(self.Frame1)
        self.Frame2_4.place(
            relx=0.0,
            rely=0.606,
            relheight=0.088,
            relwidth=0.649)
        self.Frame2_4.configure(relief='groove')
        self.Frame2_4.configure(borderwidth="2")
        self.Frame2_4.configure(relief="groove")

        self.Label1_5 = tk.Label(self.Frame2_4)
        self.Label1_5.place(relx=0.069, rely=0.1, height=65, width=93)
        self.Label1_5.configure(text='''PC用商品説明文''')
        self.Label1_5.configure(wraplength="50")

        self.catalog_caption_insert_1 = tk.Entry(self.Frame2_4)
        self.catalog_caption_insert_1.place(
            relx=0.31, rely=0.15, height=27, relwidth=0.267)

        self.catalog_caption_insert_2 = tk.Entry(self.Frame2_4)
        self.catalog_caption_insert_2.place(
            relx=0.716, rely=0.15, height=27, relwidth=0.267)

        self.Label2_4 = tk.Label(self.Frame2_4)
        self.Label2_4.place(relx=0.208, rely=0.15, height=22, width=43)
        self.Label2_4.configure(text='''挿入前''')

        self.Label3_5 = tk.Label(self.Frame2_4)
        self.Label3_5.place(relx=0.622, rely=0.15, height=22, width=43)
        self.Label3_5.configure(text='''挿入後''')

        self.catalog_caption_replace_1 = tk.Entry(self.Frame2_4)
        self.catalog_caption_replace_1.place(
            relx=0.31, rely=0.55, height=27, relwidth=0.267)

        self.catalog_caption_replace_2 = tk.Entry(self.Frame2_4)
        self.catalog_caption_replace_2.place(
            relx=0.716, rely=0.55, height=27, relwidth=0.267)

        self.Label4_4 = tk.Label(self.Frame2_4)
        self.Label4_4.place(relx=0.208, rely=0.55, height=21, width=43)
        self.Label4_4.configure(text='''置換前''')

        self.Label5_5 = tk.Label(self.Frame2_4)
        self.Label5_5.place(relx=0.622, rely=0.55, height=21, width=43)
        self.Label5_5.configure(text='''置換後''')

        self.catalog_caption_toggle_var = tk.BooleanVar()
        self.catalog_caption_toggle_var.set(toggle)
        self.catalog_caption_toggle = tk.Checkbutton(
            self.Frame2_4, variable=self.catalog_caption_toggle_var)
        self.catalog_caption_toggle.place(
            relx=0.029, rely=0.313, relheight=0.4, relwidth=0.071)

        self.toggles["catalog_caption"] = self.catalog_caption_toggle_var
        self.entries["catalog_caption"] = [
            self.catalog_caption_insert_1,
            self.catalog_caption_insert_2,
            self.catalog_caption_replace_1,
            self.catalog_caption_replace_2]

    def __smart_caption(self, toggle=False):
        self.Frame2_5 = tk.Frame(self.Frame1)
        self.Frame2_5.place(
            relx=0.0,
            rely=0.692,
            relheight=0.087,
            relwidth=0.649)
        self.Frame2_5.configure(relief='groove')
        self.Frame2_5.configure(borderwidth="2")
        self.Frame2_5.configure(relief="groove")

        self.Label1_6 = tk.Label(self.Frame2_5)
        self.Label1_6.place(relx=0.069, rely=0.101, height=64, width=93)
        self.Label1_6.configure(text='''スマートフォン用商品説明文''')
        self.Label1_6.configure(wraplength="50")

        self.smart_caption_insert_1 = tk.Entry(self.Frame2_5)
        self.smart_caption_insert_1.place(
            relx=0.31, rely=0.152, height=27, relwidth=0.267)

        self.smart_caption_insert_2 = tk.Entry(self.Frame2_5)
        self.smart_caption_insert_2.place(
            relx=0.716, rely=0.152, height=27, relwidth=0.267)

        self.Label2_5 = tk.Label(self.Frame2_5)
        self.Label2_5.place(relx=0.208, rely=0.152, height=22, width=43)
        self.Label2_5.configure(text='''挿入前''')

        self.Label3_6 = tk.Label(self.Frame2_5)
        self.Label3_6.place(relx=0.622, rely=0.152, height=22, width=43)
        self.Label3_6.configure(text='''挿入後''')

        self.smart_caption_replace_1 = tk.Entry(self.Frame2_5)
        self.smart_caption_replace_1.place(
            relx=0.31, rely=0.557, height=27, relwidth=0.267)

        self.smart_caption_replace_2 = tk.Entry(self.Frame2_5)
        self.smart_caption_replace_2.place(
            relx=0.716, rely=0.557, height=27, relwidth=0.267)

        self.Label4_5 = tk.Label(self.Frame2_5)
        self.Label4_5.place(relx=0.208, rely=0.557, height=20, width=43)
        self.Label4_5.configure(text='''置換前''')

        self.Label5_6 = tk.Label(self.Frame2_5)
        self.Label5_6.place(relx=0.622, rely=0.557, height=20, width=43)
        self.Label5_6.configure(text='''置換後''')

        self.smart_caption_toggle_var = tk.BooleanVar()
        self.smart_caption_toggle_var.set(toggle)
        self.smart_caption_toggle = tk.Checkbutton(
            self.Frame2_5, variable=self.smart_caption_toggle_var)
        self.smart_caption_toggle.place(
            relx=0.029,
            rely=0.316,
            relheight=0.392,
            relwidth=0.071)

        self.toggles["smart_caption"] = self.smart_caption_toggle_var
        self.entries["smart_caption"] = [
            self.smart_caption_insert_1,
            self.smart_caption_insert_2,
            self.smart_caption_replace_1,
            self.smart_caption_replace_2]

    def __display_caption(self, toggle=False):
        self.Frame2_6 = tk.Frame(self.Frame1)
        self.Frame2_6.place(
            relx=0.0,
            rely=0.777,
            relheight=0.087,
            relwidth=0.649)
        self.Frame2_6.configure(relief='groove')
        self.Frame2_6.configure(borderwidth="2")
        self.Frame2_6.configure(relief="groove")

        self.Label1_7 = tk.Label(self.Frame2_6)
        self.Label1_7.place(relx=0.069, rely=0.101, height=64, width=93)
        self.Label1_7.configure(text='''PC用販売説明文''')
        self.Label1_7.configure(wraplength="50")

        self.display_caption_insert_1 = tk.Entry(self.Frame2_6)
        self.display_caption_insert_1.place(
            relx=0.31, rely=0.152, height=27, relwidth=0.267)

        self.display_caption_insert_2 = tk.Entry(self.Frame2_6)
        self.display_caption_insert_2.place(
            relx=0.716, rely=0.152, height=27, relwidth=0.267)

        self.Label2_6 = tk.Label(self.Frame2_6)
        self.Label2_6.place(relx=0.208, rely=0.152, height=22, width=43)
        self.Label2_6.configure(text='''挿入前''')

        self.Label3_7 = tk.Label(self.Frame2_6)
        self.Label3_7.place(relx=0.622, rely=0.152, height=22, width=43)
        self.Label3_7.configure(text='''挿入後''')

        self.display_caption_replace_1 = tk.Entry(self.Frame2_6)
        self.display_caption_replace_1.place(
            relx=0.31, rely=0.557, height=27, relwidth=0.267)

        self.display_caption_replace_2 = tk.Entry(self.Frame2_6)
        self.display_caption_replace_2.place(
            relx=0.716, rely=0.557, height=27, relwidth=0.267)

        self.Label4_6 = tk.Label(self.Frame2_6)
        self.Label4_6.place(relx=0.208, rely=0.557, height=20, width=43)
        self.Label4_6.configure(text='''置換前''')

        self.Label5_7 = tk.Label(self.Frame2_6)
        self.Label5_7.place(relx=0.622, rely=0.557, height=20, width=43)
        self.Label5_7.configure(text='''置換後''')

        self.display_caption_toggle_var = tk.BooleanVar()
        self.display_caption_toggle_var.set(toggle)
        self.display_caption_toggle = tk.Checkbutton(
            self.Frame2_6, variable=self.display_caption_toggle_var)
        self.display_caption_toggle.place(
            relx=0.029, rely=0.316, relheight=0.392, relwidth=0.071)

        self.toggles["display_caption"] = self.display_caption_toggle_var
        self.entries["display_caption"] = [
            self.display_caption_insert_1,
            self.display_caption_insert_2,
            self.display_caption_replace_1,
            self.display_caption_replace_2]

    def __depot_flag(self, toggle=False):
        self.Frame2_5 = tk.Frame(self.Frame1)
        self.Frame2_5.place(
            relx=0.0,
            rely=0.861,
            relheight=0.054,
            relwidth=0.649)
        self.Frame2_5.configure(relief='groove')
        self.Frame2_5.configure(borderwidth="2")
        self.Frame2_5.configure(relief="groove")

        self.Label1_6 = tk.Label(self.Frame2_5)
        self.Label1_6.place(relx=0.069, rely=0.102, height=40, width=83)
        self.Label1_6.configure(text='''倉庫指定''')
        self.Label1_6.configure(wraplength="50")

        self.depot_flag_toggle_var = tk.BooleanVar()
        self.depot_flag_toggle_var.set(toggle)
        self.depot_flag_toggle = tk.Checkbutton(
            self.Frame2_5, variable=self.depot_flag_toggle_var)
        self.depot_flag_toggle.place(
            relx=0.029,
            rely=0.306,
            relheight=0.408,
            relwidth=0.071)

        self.depot_flag_var = tk.IntVar()
        self.depot_flag_1 = tk.Radiobutton(
            self.Frame2_5, variable=self.depot_flag_var, value=0)
        self.depot_flag_1.place(
            relx=0.295,
            rely=0.204,
            relheight=0.551,
            relwidth=0.153)
        self.depot_flag_1.configure(text='''販売中''')

        self.depot_flag_2 = tk.Radiobutton(
            self.Frame2_5, variable=self.depot_flag_var, value=1)
        self.depot_flag_2.place(
            relx=0.605,
            rely=0.204,
            relheight=0.551,
            relwidth=0.206)
        self.depot_flag_2.configure(text='''倉庫に入れる''')

        self.toggles["depot_flag"] = self.depot_flag_toggle_var
        self.entries["depot_flag"] = self.depot_flag_var

    def __limited_flag(self, toggle=False):
        self.Frame2_6 = tk.Frame(self.Frame1)
        self.Frame2_6.place(
            relx=0.0,
            rely=0.913,
            relheight=0.053,
            relwidth=0.649)
        self.Frame2_6.configure(relief='groove')
        self.Frame2_6.configure(borderwidth="2")
        self.Frame2_6.configure(relief="groove")

        self.Label1_7 = tk.Label(self.Frame2_6)
        self.Label1_7.place(relx=0.069, rely=0.109, height=37, width=83)
        self.Label1_7.configure(text='''サーチ非表示''')
        self.Label1_7.configure(wraplength="50")

        self.limited_flag_toggle_var = tk.BooleanVar()
        self.limited_flag_toggle_var.set(toggle)
        self.limited_flag_toggle = tk.Checkbutton(self.Frame2_6, variable=self.limited_flag_toggle_var)
        self.limited_flag_toggle.place(
            relx=0.029,
            rely=0.304,
            relheight=0.413,
            relwidth=0.071)

        self.limited_flag_checkbtn_var = tk.BooleanVar()
        self.limited_flag_checkbtn = tk.Checkbutton(self.Frame2_6, variable=self.limited_flag_checkbtn_var)
        self.limited_flag_checkbtn.place(
            relx=0.277, rely=0.217, relheight=0.522, relwidth=0.277)
        self.limited_flag_checkbtn.configure(text='''サーチ非表示にする''')

        self.toggles["limited_flag"] = self.limited_flag_toggle_var
        self.entries["limited_flag"] = self.limited_flag_checkbtn_var

    def __item_box(self):
        self.result_box_var = tk.StringVar()
        self.result_box = tk.Listbox(
            self.Frame1,
            listvariable=self.result_box_var,
            selectmode=tk.EXTENDED)
        self.result_box.place(
            relx=0.652,
            rely=0.056,
            relheight=0.776,
            relwidth=0.341)

        self.item_num_label_var = tk.StringVar()
        self.item_num_label_var.set("0件")
        self.item_num_label = tk.Label(self.Frame1, textvariable=self.item_num_label_var)
        self.item_num_label.place(relx=0.945, rely=0.022, height=27, width=43)

        self.exclusion_button = tk.Button(
            self.Frame1, command=self.exclusion_items)
        self.exclusion_button.place(relx=0.844, rely=0.844, height=44, width=127)
        self.exclusion_button.configure(text='''除外''')

    def __item_updates(self):
        self.update_button = tk.Button(self.Frame1, command=self.update_rms_items)
        self.update_button.place(relx=0.664, rely=0.934, height=44, width=137)
        self.update_button.configure(text='''更新''')

        self.cancel_button = tk.Button(self.Frame1, command=self.cancel_updates)
        self.cancel_button.place(relx=0.844, rely=0.934, height=44, width=127)
        self.cancel_button.configure(text='''停止''')


if __name__ == '__main__':
    rms = RakutenRms()
    rms.login()
    rms.updateShopsettings()

    root = tk.Tk()
    toplevel = MainWindow(rms=rms, top=root)
    root.mainloop()
#! /usr/bin/env python #  -*- coding: utf-8 -*- # # GUI module generated by PAGE version 5.3 #  in conjunction with Tcl version 8.6 #    May 26, 2020 02:41:41 PM JST  platform: Windows NT 検索 続けて検索 決定 キャンセル 商品名 挿入前 挿入後 置換前 置換後 モバイル用キャッチコピー 挿入前 挿入後 置換前 置換後 消費税率 消費税 消費税別 消費税込 配送方法セット 送料 送料別 送料無料 代引料 PC用商品説明文 挿入前 挿入後 置換前 置換後 スマートフォン用商品説明文 挿入前 挿入後 置換前 置換後 PC用販売説明文 挿入前 挿入後 置換前 置換後 倉庫指定 販売中 倉庫に入れる サーチ非表示 サーチ非表示にする 除外 更新 停止