Python Forum
How to Translate a python code written in Mac-OS to Windows?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to Translate a python code written in Mac-OS to Windows?
The code was written last year by a former colleague, and as it only works on Mac, I have to convert it to Windows.

The Python code will serve as a Bluetooth scanner searching for a device and retrieving data from the device.

I noticed one of the imported libraries is "objc".

What is the Windows equivalent of ObjC?

#!/usr/bin/env python
# -*- coding: UTF-8 -*-
import threading
import time
import os  #for Decrypt
[color=#9B59B6]import objc[/color]
from struct import *
import codecs
import numpy as np
import binascii
# my define function
Sorry, the rest of the code is intellectual property, so I cannot share the remaining.
You need to say what you're using the library for, because perhaps there are Windows-specific (or cross-platform) libraries that do similar things for the parts you're using. I can't say I know anything about Objective-C or Cocoa.

One thing you'll want to do, if you haven't already is to hide away the uses of this library behind your own abstractions (i.e. classes or function as appropriate), so that the rest of the code only depends on those abstractions. That will allow you to swap out one implementation for another. Perhaps some design patterns like bridge or adapter might also be useful to you.
The introduction of PyObjc, the project containing the objc module goes as follows
Quote:The PyObjC project aims to provide a bridge between the Python and Objective-C programming languages on macOS. The bridge is intended to be fully bidirectional, allowing the Python programmer to take full advantage of the power provided by various Objective-C based toolkits and the Objective-C programmer transparent access to Python based functionality.

PyObjC not only includes the basic bridge, but also bindings to most Apple frameworks on macOS.

The most important usage of this is writing Cocoa GUI applications on macOS in pure Python. See our tutorial for an example of this.
With this description of the project, we can assume that it is almost impossible to run the program in a Windows environment.

If however the objc module is used only for the GUI part of the program, you could perhaps rewrite only the GUI part with another GUI framework or even write a console based program with similar functionalities.

Possibly Related Threads…
Thread Author Replies Views Last Post
  Delimiters - How to skip some html tags from being translate Melcu54 0 388 May-26-2021, 06:21 AM
Last Post: Melcu54
  [split] SyntaxError when trying to execute code on Windows nehaya 2 682 Aug-04-2020, 11:18 AM
Last Post: nehaya
  SyntaxError when trying to execute code on Windows Fred0n 2 1,042 Apr-25-2020, 04:30 AM
Last Post: buran
  Translate to noob a Name Eroor message bako 2 807 Mar-30-2020, 05:58 PM
Last Post: bako
  Translate this line of code please keystone76 2 1,122 Jan-31-2020, 11:15 PM
Last Post: keystone76
  translate \ to / ? Skaperen 4 1,021 Oct-01-2019, 06:05 AM
Last Post: Skaperen
  Logger file rotation not working when python code started from windows service as exe nirvantosh 1 2,706 Jun-14-2019, 03:58 PM
Last Post: nirvantosh
  Code works in IDLE, appears to work in CMD, but won't produce files in CMD/Windows ChrisPy33 3 1,617 Jun-12-2019, 05:56 AM
Last Post: ChrisPy33
  Heating program to translate from Basic to Python tommy2k19 12 2,583 May-21-2019, 08:16 AM
Last Post: tommy2k19
  Run Script written in javascript from python Scientifix 3 1,754 Apr-28-2018, 06:48 PM
Last Post: Gribouillis

Forum Jump:

User Panel Messages

Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020