Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I shall open an Issue - Error tk Mac OSX #97

Closed
tcptps opened this issue Mar 5, 2021 · 11 comments
Closed

I shall open an Issue - Error tk Mac OSX #97

tcptps opened this issue Mar 5, 2021 · 11 comments
Assignees
Labels
bug Something isn't working

Comments

@tcptps
Copy link

tcptps commented Mar 5, 2021

It said so so I did.
Mac OS Sierra (10.12)
installed with pip (Python3.9)
launched from Terminal normcap
useful Application Window never appeared.

If you need anymore information ask for it I am happy to help.

Bildschirmfoto 2021-03-05 um 11 42 11

@tcptps tcptps changed the title I shall open an Issue I shall open an Issue - Error tk Mac OSX Mar 5, 2021
@dynobo
Copy link
Owner

dynobo commented Mar 10, 2021

Thanks for the report, @tcptps ! 👍
I actually didn't test on MacOS for quite a while (I don't have a Mac myself), but I try to take a look at it next weekend.

@dynobo dynobo self-assigned this Mar 10, 2021
@dynobo dynobo added the bug Something isn't working label Mar 10, 2021
@dynobo
Copy link
Owner

dynobo commented Mar 20, 2021

Hi @tcptps,

today I installed Sierra in a VM and tried to reproduce the issue, but without success. To me, it seems like everything's working as expected.

Can you please provide additional information?

  1. Do you have a multi-monitor setup or only one display?
  2. You wrote "useful Application Window never appeared.". Are you sure? The "application window" is barely visible, because it shows only a screenshot from your current desktop. The red border it draws (see screenshot) is basically the only thing visible:
    2021-03-20_18-25
    If you see the red border, try selecting a portion of the screen with text using the mouse to trigger the recognition process.
  3. I'm not so familiar with MacOS, but I know there are some options how application windows show up. I think you can configure Mac to always maximize windows or something. Do you have something like that configure?

Thanks!

@tcptps
Copy link
Author

tcptps commented Mar 20, 2021

Hi,

  1. one Display
  2. No red border for me.
  3. Thats a weird one I have to say, because the Menu bar is hidden which is normally a sign that an application is in full Screen mode but on the other hand there is the little window. Using python 3.9 I think I used the Installer from the python website.
    Since my Setup is weird sometimes and it works in your VM I would suggest to wait if somebody else experiences the same Problem and assume my Setup is just broken somehow. If there is any test I can run let me know. I tried using the development Environment: https://github.com/dynobo/normcap#setup-environment but no luck either:

Bildschirmfoto 2021-03-20 um 20 31 56

Thank you very much for taking care.

@dynobo
Copy link
Owner

dynobo commented Mar 21, 2021

You observations are quite interesting!

What technically should happen is, that normcap opens two windows:

  1. A "dummy" window, which seems to be necessary to receive keyboard shortcuts. This is the small window you see that prompts you to report the bug.
  2. Window 1) should never be visible, because a child window should open fullscreen in front of it showing the screenshot with red border. (In multi-monitor setup, one child window per screen is spawned)

Setting window 2) to fullscreen was quite difficult, because the behavior is different across the operation systems and because I also wanted multi-monitor setup. Especially on MacOS it was a struggle. The best I could come up with so far is a certain combination of options. If you are familiar with Python, this would be the section of code to experiment with.

Now the interesting part for me:
While I read, that the options I use for Mac should result in a fullscreen and topmost window, in my tests it never really was topmost: menubar and dock always were in front of it (in my screenshot above, you the red border end below menubar). I thought this might be the MacOS way, not allowing a real top-most window. In your screenshot on the other hand, it seems like menubar and dock are somehow hidden, which is quite interesting.

It looks a bit like in your case fullscreen mode is somehow enabled, but window 2) just not visible. Maybe it is not at the correct position/size...

In any case, I'd be happy about help or hints anyone.

@dynobo dynobo added the help wanted Looking for contributors to work on this issue label Mar 21, 2021
@dynobo
Copy link
Owner

dynobo commented Apr 4, 2021

I tried a change which might fix this problem. Could anyone affected by this issue please try v0.1.11 and report back?

pip install normcap==0.1.11

@9001
Copy link

9001 commented Apr 9, 2021

just bumped into your project through mss, cool stuff :>
noticed this issue and gave it a try since i had a mac nearby.

encountered somewhat similar behavior on 0.1.10:

  • the red border is painted on startup, however the menu bar is on a layer above the border and renders over it
  • capturing contents inside the menu bar is impossible; normcap reports that nothing was captured
  • the dummy window appears when initiating the selection (click/drag)

can confirm that 0.1.11 mostly fixes both of these in my case;

  • the red border is still covered by the menu bar until the left mouse button is clicked, this immediately makes the border top-level
  • ...so capturing contents inside the menu bar is now possible by starting a selection right below it
  • the dummy window no longer appears at all

this was using the system-provided python 3.8 and tkinter on catalina 10.15.7

@dynobo
Copy link
Owner

dynobo commented Apr 10, 2021

@9001 Thanks for your valuable feedback! This seems like updating to v0.1.11 is a good workaround for people on MacOS affected by this issue,

I leave this ticket open, because it still doesn't behave as it should (menu bar should be covered, too.)

I'm currently experimenting with a different GUI-Framework (Kivy) that hopefully fixes this issue and makes other things more easier for me, too. I'll drop a notice here, as soon as it's ready for testing.

@y4rr
Copy link

y4rr commented May 27, 2021

@dynobo I'm not a super expert in developing for MacOS, but I think I may have here something interesting for you. Here's an example of how to use Python and the PyObjC library to draw a window which in the fullscreen mode will render over the menu bar:

import objc
from Foundation import NSObject
from AppKit import NSApp, NSApplication, NSWindow, NSScreen, NSNormalWindowLevel, NSFloatingWindowLevel, NSTitledWindowMask, NSResizableWindowMask, NSClosableWindowMask, NSBorderlessWindowMask, NSBackingStoreBuffered, NSWindowCollectionBehaviorFullScreenPrimary
from PyObjCTools import AppHelper


class MyWindow(NSObject):
    def __new__(cls, *args, **kwargs):
        return cls.alloc().init()

    def __init__(self):
        frame = ((0.0, 0.0), (640.0, 480.0))
        mask = NSTitledWindowMask | NSResizableWindowMask | NSClosableWindowMask | NSBorderlessWindowMask
        screen = NSScreen.mainScreen()
        #level = NSFloatingWindowLevel
        # It's just an integer, you can set it for something ridiculously high, so for example in the full screen mode the window will render over the menu bar and the dock
        level = 999999
        self._window = NSWindow.alloc().initWithContentRect_styleMask_backing_defer_screen_(frame, mask, NSBackingStoreBuffered, False, screen)
        self._window.setTitle_("Hello World")
        self._window.setLevel_(level)
        self._window.setDelegate_(self)
        self._window.setCollectionBehavior_(NSWindowCollectionBehaviorFullScreenPrimary)
        self._window.makeKeyAndOrderFront_(self)
        self._window.retain()


def main():
    app = NSApplication.sharedApplication()

    win = MyWindow()

    NSApp.activateIgnoringOtherApps_(True)

    AppHelper.runEventLoop()

if __name__ == "__main__":
    main()

I hope this might be useful for this issue. I think that you could try to use the same Objective-C APIs with tcl/tk.

@dynobo
Copy link
Owner

dynobo commented May 27, 2021

@y4rr Thanks a lot for your efforts and this information. I'm currently working hard on a switch from Tk to Qt (see the respective branch), which hopefully makes it more easy to maintain NormCap for multiple platforms.

Interestingly, showing the fullscreen already works quite well with Qt on MacOS, but there are some other Mac-specific issues I have to sort out, e.g. I can't change the cursor to crosshair yet and the window doesn't get focused to receive keypress events... But maybe objc can be of use here, too! :-)

@dynobo
Copy link
Owner

dynobo commented May 29, 2021

In the new beta release 0.2.0-b1 I got completely rid of the "dummy window". In general it should provide a much nicer experience on MacOS (still not perfect, e.g. it still is behind the application menu and dock).

Please help by testing and providing feedback.

@dynobo
Copy link
Owner

dynobo commented Jun 23, 2021

The issue with "dummy window" is solved with #116 and has been published in the new v0.2.0b3.

For the problem that the window stay below the menubar, I created Issue #119

@dynobo dynobo closed this as completed Jun 23, 2021
@dynobo dynobo removed the help wanted Looking for contributors to work on this issue label Feb 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants