Re: Adding Text Screens

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 8 Jan 2003, Brent Clements wrote:

>  I would like to add a text screen to anaconda so that I can select a choice
> then once ok is pressed, an action would occur.

I should write up a doc on this or something.  It's a little confusing, 
but it's not really that hard.  You'll need to create a window class 
module in textw/ which contains all of the code for painting the window.  
Then you register your class by adding an entry in stepToClasses{} in 
text.py.  After that you need to make a change in installclass.py to 
setStepList() which will tell the installer to use your new screen as one 
of the steps.

I made a posting to the list last November which explained how to do this.  
Here's a repost.  Hope it helps.


--Patrick.


----------------->8 snippy snippy 8<-------------------

On Thu, 7 Nov 2002, Alisha Nigam wrote:

> hi
>
>      During installation of RedHat-7.2 before disk
> partioning  i want to incorporate a program that
> will ask user to insert a floppy & the will copy
> some user given files to the floppy.

I wrote some code which would do something really similar to this.  What I
ended up doing was creating a new window class which prompts for a floppy
disk.  Call this something like "floppycopy_[text|gui].py" (I've only done
this with text mode, but I'm certain doing it for the gui would be really
similar).

.......

import os
import sys
import string
import isys

from snack import *
from constants_text import *
from translate import _
import iutil
import network


class FloppyDiskWindow:
    def __call__ (self, screen, intf, id):

        device = id.floppyDevice
        file = "/tmp/floppy"

        isys.makeDevInode(device, file)

        while 1:

            rc = ButtonChoiceWindow(screen, _("Floppy Disk Copy"),
                                _("Please insert a blank floppy diskette "
                                  "into the floppy disk drive."),
                                buttons = [TEXT_OK_BUTTON], width = 50,
                                help = "welcome")

            try:
                fd = os.open(file, os.O_RDONLY)
            except:
                intf.messageWindow( _("Error"),
                    _("An error occured while creating the floppy disk. "
                      "Please make sure that there is a formatted floppy "
                      "in the first floppy drive."))
                continue

            os.close(fd)

            args = [ 'mkdosfs', '/tmp/floppy' ]
            cmd = "/usr/sbin/mkdosfs"

            if os.access("/sbin/mkdosfs", os.X_OK):
                cmd = "/sbin/mkdosfs"

            iutil.execWithRedirect (cmd, args, stdout = '/dev/tty5',
                                stderr = '/dev/tty5')

            isys.mount(device, "/tmp/crash", fstype = "vfat")

            try:
                iutil.copyFile("/tmp/filetocopy",
                    "/tmp/crash/filetocopy")
            except:
                pass

            isys.umount("/tmp/crash")

            return INSTALL_OK


......

Next you need to need to 'register' the class by making an entry in the
stepToClasses{} (which is in text.py for doing this in text mode).  It
should be something similar to:

stepToClasses = {
    "floppycopy" : ("floppycopy_text", "FloppyDiskWindow"),
    ...
}

The 'floppycopy' key is going to point at your new class
"FloppyDiskWindow" inside the file 'floppycopy_text.py'.

Now you need to edit dispatch.py and set up which arguments are going to
be sent to your new class.  Add another entry to installSteps[] with
something like:

installSteps = [
    ("floppycopy", ("intf", "id")),
    ...
]

If you look back at the FloppyDiskWindow class, we're expecting to get
"intf" and "id" passed as arguments.

The only thing left is we need to put our new step "floppycopy" into the
StepList in the install class.  Edit the file 'installclass.py', and add
the entry "floppycopy" into the setStepList() class in setSteps.  This
should look something like:

    def setSteps(self, dispatch):
        dispatch.setStepList(
                 "language",
                 "keyboard",
                 "mouse",
                 "welcome",
                 "installtype",
                 "floppycopy",
                 ...


That's all there is to it.  You might want to change the window screen to
allow you to skip writing the floppy ever time though, as well as adding a
"Back" button to it.  Hope it helps..

--Patrick.








[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux