On Thu, Apr 02, 2015 at 10:41:18AM -0700, Martin wrote:
> You are right, the following works as intended
> 
> groups = [Group(i) for i in "neio"]
> 
> for i in groups:
>     keys.append(
>         Key([mod], i.name, lazy.group[i.name].toscreen())
>     )
> 
> # Append ' key group
> a = Group("'")
> keys.append(
>     Key([mod], 'apostrophe', lazy.group[a.name].toscreen())
> )
> groups.append(a)  # Here is the fix
> 
> But why is this the case? I don't see the 'groups' variable used anywhere 
> else in the config, except the for loop.
> It turns out that if I rename the groups variable to something else, the 
> groups will be defined by default Qtile settings.
> 
> In other words, groups is a magic variable of some sort. I am not a very 
> good programmer, but isn't this a bit odd and counterintuitive? To me, the 
> following or something similar would make more sense:
> 
> from libqtile.config import Group
> Group.groups = ....
> 
> Is groups a global variable?

When qtile starts, it actually imports your config as a module and
looks for a few variables (e.g. groups, screens, keys, etc.) in that
module which define your config. So it's "module global" I guess you
could say, but it is namespaced because it's in your config.

Tycho

> Btw, thanks for the help, it works like a charm :)
> 
> On Thursday, April 2, 2015 at 10:49:00 AM UTC-4, Roger wrote:
> >
> >
> > On Apr 2, 2015 11:37 AM, "Martin" <[email protected] <javascript:>> 
> > wrote:
> > >
> > > I would like to use the appostrophe character as a group, but I can't 
> > get it to work properly.
> > >
> > > This is what I try:
> > >
> > > # Regular key assignment
> > > group_str = "hneio"  # Apostrophe is right next to o character and would 
> > be super convenient to use
> > > # Yes, my keyboard layout is a bit unusual
> > >
> > > groups = [Group(i) for i in group_str]
> > >
> > > for i in groups:
> > >     # mod1 + letter of group = switch to group
> > >     keys.append(
> > >         Key([mod], i.name, lazy.group[i.name].toscreen())
> > >     )
> > >     # mod1 + shift + letter of group = switch to & move focused window 
> > to group
> > >     keys.append(
> > >         Key([mod, "shift"], i.name, lazy.window.togroup(i.name))
> > >     )
> > > # Append special ' key group outside for loop
> > > a = Group("Q")  # Name shouldn't be an issue
> > you have to put this group, a, inside groups list
> >
> > > keys.append(
> > >     Key([mod], 'apostrophe', lazy.group[a.name].toscreen())
> > > )
> > > keys.append(
> > >     Key([mod, "shift"], 'apostrophe', lazy.window.togroup(a.name))
> > > )
> > >
> > > Using MOD+' and MOD+SHIFT+' actually activates the lazy.group commands, 
> > but it gives an error and the output is
> > >
> > > 2015-04-02 10:28:01,394 qtile handle_KeyPress:855  KB command error 
> > toscreen: No object group['Q'] in path 'group['Q']'
> > > 2015-04-02 10:28:03,433 qtile _xpoll:656  Handling: KeyPress
> > > 2015-04-02 10:28:03,433 qtile handle_KeyPress:855  KB command error 
> > toscreen: No object group['Q'] in path 'group['Q']'
> > > 2015-04-02 10:28:04,213 qtile _xpoll:656  Handling: KeyPress
> > > 2015-04-02 10:28:04,214 qtile call:91  Command: togroup(('Q',), {})
> > > 2015-04-02 10:28:04,214 qtile handle_KeyPress:855  KB command error 
> > togroup: No such group: Q
> > > 2015-04-02 10:28:05,056 qtile _xpoll:656  Handling: KeyPress
> > > 2015-04-02 10:28:05,056 qtile call:91  Command: togroup(('Q',), {})
> > > 2015-04-02 10:28:05,057 qtile handle_KeyPress:855  KB command error 
> > togroup: No such group: Q
> > >
> > > Any idea of what is going wrong here? If I test the code, everything 
> > works but there is no Q group in the GroupBox widget and the command gives 
> > a non-critical error. Even if I don't use approstrophe, I cannot assign a 
> > group outside the for i in groups: for loop. Why not? 
> > >
> > > I don't know how I would assign the apostrophe inside the for loop. I 
> > have tried:
> > >
> > > groups = [Group(i) for i in "hneio'"]
> > > groups = [Group(i) for i in "hneio\'"]
> > >
> > > with no success. 
> > >
> > > -- 
> > > You received this message because you are subscribed to the Google 
> > Groups "qtile-dev" group.
> > > To unsubscribe from this group and stop receiving emails from it, send 
> > an email to [email protected] <javascript:>.
> > > For more options, visit https://groups.google.com/d/optout.
> >  
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "qtile-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"qtile-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to