当前位置: 首页>>代码示例>>Python>>正文


Python Window.set_action_panel方法代码示例

本文整理汇总了Python中window.Window.set_action_panel方法的典型用法代码示例。如果您正苦于以下问题:Python Window.set_action_panel方法的具体用法?Python Window.set_action_panel怎么用?Python Window.set_action_panel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在window.Window的用法示例。


在下文中一共展示了Window.set_action_panel方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: LinuxSelector

# 需要导入模块: from window import Window [as 别名]
# 或者: from window.Window import set_action_panel [as 别名]
class LinuxSelector(object):
    def __init__(self, maxy, maxx, install_config):
        self.install_config = install_config
        self.maxx = maxx
        self.maxy = maxy
        self.win_width = 60
        self.win_height = 13

        self.win_starty = (self.maxy - self.win_height) / 2
        self.win_startx = (self.maxx - self.win_width) / 2

        self.menu_starty = self.win_starty + 6

        self.menu_items = []
        self.menu_items.append(("1. Hypervisor optimized", self.set_linux_esx_installation, True))
        self.menu_items.append(("2. Generic", self.set_linux_esx_installation, False))

        self.host_menu = Menu(self.menu_starty, self.maxx, self.menu_items,
                              default_selected=0, tab_enable=False)

        self.window = Window(self.win_height, self.win_width, self.maxy, self.maxx,
                             'Select Linux kernel to install', True, items=[], tab_enabled=False,
                             position=1, can_go_next=True)
        self.window.set_action_panel(self.host_menu)

    def set_linux_esx_installation(self, is_linux_esx):
        self.install_config['install_linux_esx'] = is_linux_esx
        return ActionResult(True, None)

    def display(self, params):
        self.window.addstr(0, 0, 'The installer has detected that you are installing')
        self.window.addstr(1, 0, 'Photon OS on a VMware hypervisor.')
        self.window.addstr(2, 0, 'Which type of Linux kernel would you like to install?')
        return self.window.do_action()
开发者ID:megacoder,项目名称:photon,代码行数:36,代码来源:linuxselector.py

示例2: WindowStringReader

# 需要导入模块: from window import Window [as 别名]
# 或者: from window.Window import set_action_panel [as 别名]
class WindowStringReader(object):
    def __init__(self, maxy, maxx, height, width, field, confirmation_err_msg,
                 echo_char, accepted_chars, validation_fn, conversion_fn, title,
                 display_string, inputy, install_config, default_string=None,
                 tab_enabled=False):
        self.title = title
        self.display_string = display_string
        self.install_config = install_config
        self.inputy = inputy

        self.width = width
        self.height = height
        self.maxx = maxx
        self.maxy = maxy

        self.startx = (self.maxx - self.width) // 2
        self.starty = (self.maxy - self.height) // 2
        self.tab_enabled = False
        self.can_go_next = True

        self.window = Window(self.height, self.width, self.maxy, self.maxx, self.title,
                             True, tab_enabled=self.tab_enabled,
                             position=1, can_go_next=self.can_go_next, read_text=self.can_go_next)
        self.read_text = ReadText(maxy, maxx, self.window.content_window(), self.inputy,
                                  install_config,
                                  field, confirmation_err_msg, echo_char, accepted_chars,
                                  validation_fn,
                                  conversion_fn, default_string, tab_enabled=self.tab_enabled)
        self.window.set_action_panel(self.read_text)
        self.window.addstr(0, 0, self.display_string)

    def get_user_string(self, params):
        return self.window.do_action()
开发者ID:frapposelli,项目名称:photon,代码行数:35,代码来源:windowstringreader.py

示例3: WindowStringReader

# 需要导入模块: from window import Window [as 别名]
# 或者: from window.Window import set_action_panel [as 别名]
class WindowStringReader(object):
    def __init__(self, maxy, maxx, height, width, ispassword, confirm_password, title, display_string, inputy, install_config):
        self.title = title
        self.display_string = display_string
        self.inputy = inputy

        self.width = width
        self.height = height
        self.maxx = maxx
        self.maxy = maxy

        self.startx = (self.maxx - self.width) / 2
        self.starty = (self.maxy - self.height) / 2

        self.window = Window(self.height, self.width, self.maxy, self.maxx, self.title, True)
        self.read_text = ReadText(maxy, maxx, self.window.content_window(), self.inputy, install_config, ispassword, confirm_password)
        self.window.set_action_panel(self.read_text)
        self.window.addstr(0, 0, self.display_string)

    def get_user_string(self, params):
        return self.window.do_action()
开发者ID:bgrissin,项目名称:photon,代码行数:23,代码来源:windowstringreader.py

示例4: License

# 需要导入模块: from window import Window [as 别名]
# 或者: from window.Window import set_action_panel [as 别名]
class License(object):
    def __init__(self, maxy, maxx):
        self.maxx = maxx
        self.maxy = maxy
        self.win_width = maxx - 4
        self.win_height = maxy - 4

        self.win_starty = (self.maxy - self.win_height) // 2
        self.win_startx = (self.maxx - self.win_width) // 2

        self.text_starty = self.win_starty + 4
        self.text_height = self.win_height - 6
        self.text_width = self.win_width - 6

        self.window = Window(self.win_height, self.win_width, self.maxy, self.maxx,
                             'Welcome to the Photon installer', False)

    def display(self, params):
        accept_decline_items = [('<Accept>', self.accept_function),
                                ('<Cancel>', self.exit_function)]

        title = 'VMWARE 2.0 LICENSE AGREEMENT'
        self.window.addstr(0, (self.win_width - len(title)) // 2, title)
        self.text_pane = TextPane(self.text_starty, self.maxx, self.text_width,
                                  "EULA.txt", self.text_height, accept_decline_items)

        self.window.set_action_panel(self.text_pane)

        return self.window.do_action()


    def accept_function(self):
        return ActionResult(True, None)

    def exit_function(self):
        exit(0)
开发者ID:TiejunChina,项目名称:photon,代码行数:38,代码来源:license.py

示例5: SelectDisk

# 需要导入模块: from window import Window [as 别名]
# 或者: from window.Window import set_action_panel [as 别名]
class SelectDisk(object):
    def __init__(self,  maxy, maxx, install_config):
        self.install_config = install_config
        self.menu_items = []

        self.maxx = maxx
        self.maxy = maxy
        self.win_width = 70
        self.win_height = 16

        self.win_starty = (self.maxy - self.win_height) / 2
        self.win_startx = (self.maxx - self.win_width) / 2

        self.menu_starty = self.win_starty + 6
        self.menu_height = 5

        self.window = Window(self.win_height, self.win_width, self.maxy, self.maxx, 'Setup your disk', True)
        self.devices = Device.refresh_devices()

    def guided_partitions(self, device_index):
        menu_height = 9
        menu_width = 40
        menu_starty = (self.maxy - menu_height) / 2 + 5
        confrim_window = ConfirmWindow(menu_height, menu_width, self.maxy, self.maxx, menu_starty, 'This will erase the disk.\nAre you sure?')
        confirmed = confrim_window.do_action().result['yes']
        
        if not confirmed:
            return ActionResult(confirmed, None)
        
        #self.install_config['disk'] = self.devices[device_index].path
        #return ActionResult(True, None)
        
        # Do the partitioning
        self.window.clearerror()
        json_ret = subprocess.check_output(['gpartedbin', 'defaultpartitions', self.devices[device_index].path], stderr=open(os.devnull, 'w'))
        json_dct = json.loads(json_ret)
        if json_dct['success']:
            self.install_config['disk'] = json_dct['data']
        else:
            self.window.adderror('Partitioning failed, you may try again')
        return ActionResult(json_dct['success'], None)

    def display(self, params):
        self.window.addstr(0, 0, 'First, we will setup your disks.\n\nWe have detected {0} disks, choose disk to be auto-partitioned:'.format(len(self.devices)))

        self.disk_menu_items = []

        # Fill in the menu items
        for index, device in enumerate(self.devices):
            #if index > 0:
                self.disk_menu_items.append(
                        (
                            '{2} - {1} MB @ {0}'.format(device.path, device.size, device.model), 
                            self.guided_partitions, 
                            index
                        )
                    )

        self.disk_menu = Menu(self.menu_starty,  self.maxx, self.disk_menu_items, self.menu_height)

        self.window.set_action_panel(self.disk_menu)

        return self.window.do_action()
开发者ID:Andrew219,项目名称:photon,代码行数:65,代码来源:selectdisk.py

示例6: PartitionISO

# 需要导入模块: from window import Window [as 别名]
# 或者: from window.Window import set_action_panel [as 别名]
class PartitionISO(object):
    def __init__(self, maxy, maxx, install_config):
        self.maxx = maxx
        self.maxy = maxy
        self.win_width = maxx - 4
        self.win_height = maxy - 4
        self.install_config = install_config
        self.path_checker = []

        self.win_starty = (self.maxy - self.win_height) // 2
        self.win_startx = (self.maxx - self.win_width) // 2

        self.text_starty = self.win_starty + 4
        self.text_height = self.win_height - 6
        self.text_width = self.win_width - 6
        self.install_config['partitionsnumber'] = 0
        self.devices = Device.refresh_devices_bytes()
        self.has_slash = False
        self.has_remain = False
        self.has_empty = False

        self.disk_size = []
        for index, device in enumerate(self.devices):
            self.disk_size.append((device.path, int(device.size) / 1048576))

        self.window = Window(self.win_height, self.win_width, self.maxy, self.maxx,
                             'Welcome to the Photon installer', False, can_go_next=False)
        Device.refresh_devices()

    def display(self, params):
        if 'skipPrevs' in self.install_config and self.install_config['skipPrevs'] == True:
            self.delete()
            return ActionResult(False, {'goBack':True})
        if 'autopartition' in self.install_config and self.install_config['autopartition'] == True:
            return ActionResult(True, None)
        if ('delete_partition' in self.install_config and
                self.install_config['delete_partition'] == True):
            self.delete()
            self.install_config['delete_partition'] = False

        self.device_index = self.install_config['diskindex']

        self.disk_buttom_items = []
        self.disk_buttom_items.append(('<Next>', self.next))
        self.disk_buttom_items.append(('<Create New>', self.create_function))
        self.disk_buttom_items.append(('<Delete All>', self.delete_function))
        self.disk_buttom_items.append(('<Go Back>', self.go_back))

        self.text_items = []
        self.text_items.append(('Disk', 20))
        self.text_items.append(('Size', 5))
        self.text_items.append(('Type', 5))
        self.text_items.append(('Mountpoint', 20))
        self.table_space = 5

        title = 'Current partitions:\n'
        self.window.addstr(0, (self.win_width - len(title)) // 2, title)

        info = ("Unpartitioned space: " +
                str(self.disk_size[self.device_index][1])+
                " MB, Total size: "+
                str(int(self.devices[self.device_index].size)/ 1048576) + " MB")

        self.text_pane = TextPane(self.text_starty, self.maxx, self.text_width,
                                  "EULA.txt", self.text_height, self.disk_buttom_items,
                                  partition=True, popupWindow=True,
                                  install_config=self.install_config,
                                  text_items=self.text_items, table_space=self.table_space,
                                  default_start=1, info=info,
                                  size_left=str(self.disk_size[self.device_index][1]))

        self.window.set_action_panel(self.text_pane)

        return self.window.do_action()

    def validate_partition(self, pstr):
        if not pstr:
            return ActionResult(False, None)
        sizedata = pstr[0]
        mtdata = pstr[2]
        typedata = pstr[1]
        devicedata = self.devices[self.device_index].path

        #no empty fields unless swap
        if (typedata == 'swap' and
                (len(mtdata) != 0 or len(typedata) == 0 or len(devicedata) == 0)):
            return False, "invalid swap data "

        if (typedata != 'swap' and
                (len(sizedata) == 0 or
                 len(mtdata) == 0 or
                 len(typedata) == 0 or
                 len(devicedata) == 0)):
            if not self.has_empty and mtdata and typedata and devicedata:
                self.has_empty = True
            else:
                return False, "Input cannot be empty"

        if typedata != 'swap' and typedata != 'ext3' and typedata != 'ext4':
            return False, "Invalid type"
#.........这里部分代码省略.........
开发者ID:TiejunChina,项目名称:photon,代码行数:103,代码来源:partitionISO.py

示例7: SelectDisk

# 需要导入模块: from window import Window [as 别名]
# 或者: from window.Window import set_action_panel [as 别名]
class SelectDisk(object):
    def __init__(self,  maxy, maxx, install_config):
        self.install_config = install_config
        self.menu_items = []

        self.maxx = maxx
        self.maxy = maxy
        self.win_width = 70
        self.win_height = 16

        self.win_starty = (self.maxy - self.win_height) / 2
        self.win_startx = (self.maxx - self.win_width) / 2

        self.menu_starty = self.win_starty + 6
        self.menu_height = 5
        self.progress_padding = 5
        self.progress_width = self.win_width - self.progress_padding
        self.progress_bar = ProgressBar(self.win_starty + 6, self.win_startx + self.progress_padding / 2, self.progress_width)

        self.window = Window(self.win_height, self.win_width, self.maxy, self.maxx, 'Setup your disk', True)
        self.devices = Device.refresh_devices()

    def guided_partitions(self, device_index):
        menu_height = 9
        menu_width = 40
        menu_starty = (self.maxy - menu_height) / 2 + 5
        confrim_window = ConfirmWindow(menu_height, menu_width, self.maxy, self.maxx, menu_starty, 'This will erase the disk.\nAre you sure?')
        confirmed = confrim_window.do_action().result['yes']

        if not confirmed:
            return ActionResult(confirmed, None)

        self.progress_bar.initialize('Partitioning...')
        self.progress_bar.show()
        self.progress_bar.show_loading('Partitioning')

        # Do the partitioning
        self.window.clearerror()
        partitions_data = modules.commons.partition_disk(self.devices[device_index].path, modules.commons.default_partitions)
        if partitions_data == None:
            self.window.adderror('Partitioning failed, you may try again')
        else:
            self.install_config['disk'] = partitions_data

        self.progress_bar.hide()
        return ActionResult(partitions_data != None, None)

    def display(self, params):
        self.window.addstr(0, 0, 'First, we will setup your disks.\n\nWe have detected {0} disks, choose disk to be auto-partitioned:'.format(len(self.devices)))

        self.disk_menu_items = []

        # Fill in the menu items
        for index, device in enumerate(self.devices):
            #if index > 0:
                self.disk_menu_items.append(
                        (
                            '{2} - {1} @ {0}'.format(device.path, device.size, device.model), 
                            self.guided_partitions, 
                            index
                        )
                    )

        self.disk_menu = Menu(self.menu_starty,  self.maxx, self.disk_menu_items, self.menu_height)

        self.window.set_action_panel(self.disk_menu)
        return self.window.do_action()
开发者ID:BillTheBest,项目名称:photon,代码行数:69,代码来源:selectdisk.py

示例8: SelectDisk

# 需要导入模块: from window import Window [as 别名]
# 或者: from window.Window import set_action_panel [as 别名]
class SelectDisk(object):
    def __init__(self,  maxy, maxx, install_config):
        self.install_config = install_config
        self.menu_items = []

        self.maxx = maxx
        self.maxy = maxy
        self.win_width = 70
        self.win_height = 16

        self.win_starty = (self.maxy - self.win_height) / 2
        self.win_startx = (self.maxx - self.win_width) / 2

        self.menu_starty = self.win_starty + 6
        self.menu_height = 5
        self.progress_padding = 5
        self.progress_width = self.win_width - self.progress_padding
        self.progress_bar = ProgressBar(self.win_starty + 6, self.win_startx + self.progress_padding / 2, self.progress_width, new_win=True)

        self.disk_buttom_items = []
        self.disk_buttom_items.append(('<Custom>', self.custom_function, False))
        self.disk_buttom_items.append(('<Auto>', self.auto_function, False))

        self.window = Window(self.win_height, self.win_width, self.maxy, self.maxx, 'Select a disk', True, items = self.disk_buttom_items, menu_helper = self.save_index, position = 2, tab_enabled=False)
        self.partition_window = Window(self.win_height, self.win_width, self.maxy, self.maxx, 'Partition', True)
        self.devices = Device.refresh_devices()

    def guided_partitions(self, params):
        if not 'diskindex' in self.install_config:
            return ActionResult(False, None);

        device_index = self.install_config['diskindex']

        menu_height = 9
        menu_width = 40
        menu_starty = (self.maxy - menu_height) / 2 + 5
        self.install_config['delete_partition'] = True
        confrim_window = ConfirmWindow(menu_height, menu_width, self.maxy, self.maxx, menu_starty, 'This will erase the disk.\nAre you sure?')
        confirmed = confrim_window.do_action().result['yes']

        if confirmed == False:
            self.install_config['skipPrevs'] = True
            return ActionResult(False, {'goBack':True})

        self.install_config['skipPrevs'] = False
        self.progress_bar.initialize('Partitioning...')
        self.progress_bar.show()
        self.progress_bar.show_loading('Partitioning')

        # Do the partitioning
        if 'partitionsnumber' in self.install_config:
                if (int(self.install_config['partitionsnumber']) == 0):
                    partitions_data = modules.commons.partition_disk(self.devices[device_index].path, modules.commons.default_partitions)
                else:
                    partitions = []
                    for i in range (int (self.install_config['partitionsnumber'])):
                        if len(self.install_config[str(i)+'partition_info'+str(0)])==0:
                            sizedata=0
                        else:
                            sizedata = int(self.install_config[str(i)+'partition_info'+str(0)])
                        mtdata = self.install_config[str(i)+'partition_info'+str(2)]
                        typedata = self.install_config[str(i)+'partition_info'+str(1)]

                        partitions = partitions + [
                                    {"mountpoint": mtdata, "size": sizedata, "filesystem": typedata},
                                    ]
                    partitions_data = modules.commons.partition_disk(self.devices[device_index].path, partitions)
        else: 
            partitions_data = modules.commons.partition_disk(self.devices[device_index].path, modules.commons.default_partitions)

        if partitions_data == None:
            self.partition_window.adderror('Partitioning failed, you may try again')
        else:
            self.install_config['disk'] = partitions_data

        self.progress_bar.hide()
        return ActionResult(partitions_data != None, None)

    def display(self, params):
        if 'skipPrevs' in self.install_config:
            self.install_config['skipPrevs'] = False
        self.window.addstr(0, 0, 'Please select a disk and a method how to partition it:\nAuto - single partition for /, no swap partition.\nCustom - for customized partitioning')

        self.disk_menu_items = []

        # Fill in the menu items
        for index, device in enumerate(self.devices):
            #if index > 0:
                self.disk_menu_items.append(
                        (
                            '{2} - {1} @ {0}'.format(device.path, device.size, device.model), 
                            self.save_index, 
                            index
                        )
                    )

        self.disk_menu = Menu(self.menu_starty,  self.maxx, self.disk_menu_items, self.menu_height, tab_enable=False)
        self.disk_menu.can_save_sel(True)

        self.window.set_action_panel(self.disk_menu)
#.........这里部分代码省略.........
开发者ID:megacoder,项目名称:photon,代码行数:103,代码来源:selectdisk.py


注:本文中的window.Window.set_action_panel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。